Class StructuredLogRecordMapping
Maps a LogEntry to the generic StructuredRecord shape, and builds the stream-scoped ordering/filter pieces UnityStructuredLogService needs to trim its own table.
Inherited Members
Namespace: Serenity.StructuredLogging.Infrastructure
Assembly: Serenity.UnityStructuredLogging.Infrastructure.dll
Syntax
public static class StructuredLogRecordMapping
Fields
SessionId
The process-lifetime session identifier stamped on every record, correlating all entries of one app run. Generated once per process at first use — deliberately Unity-free, so static initialization is safe on any thread.
Declaration
public static readonly string SessionId
Field Value
| Type | Description |
|---|---|
| string |
Methods
BuildStreamScopeFilters(string)
Builds the log_stream = streamId scope filter shared by every stream-scoped operation.
Declaration
public static IReadOnlyList<FieldFilter> BuildStreamScopeFilters(string streamId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | streamId |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<FieldFilter> |
BuildTrimOrderFields()
Builds the trim/query ordering: newest first by UtcTicksField, then by SequenceField as a tie-break. The sequence — not the store-assigned IdField — is the tie-break because every record carries it on every backend, while the identity column only exists on backends that assign one.
Declaration
public static IReadOnlyList<OrderField> BuildTrimOrderFields()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<OrderField> |
ToRecord(LogEntry, string, string)
Maps a LogEntry to its StructuredRecord field representation
for the given stream, stamping the process-wide SessionId and the next
value of a process-wide monotonically increasing write sequence. The sequence exists
because DateTime.UtcNow ticks over at the system timer's resolution (about 15
milliseconds on Windows): two entries written inside the same tick would otherwise trim
non-deterministically on backends without a store-assigned identity. Both severity
columns are derived from the same enum value at the same call site so they cannot
desynchronize.
Declaration
public static StructuredRecord ToRecord(LogEntry entry, string streamId, string buildVersion)
Parameters
| Type | Name | Description |
|---|---|---|
| LogEntry | entry | The log entry to map. |
| string | streamId | The fixed partition the record is written under. |
| string | buildVersion | The application build version, captured on the main thread by the installer. Null or empty maps to a null column value. |
Returns
| Type | Description |
|---|---|
| StructuredRecord |