LogEvent class

The single, immutable representation of a log call inside steno.

LogEvent is the central data type of the entire library. Every other layer — scopes, spans, formatters, sinks — is built around it. Steno deliberately avoids designing the API around formatted strings: a log is data first, with a human-readable message alongside structured context, an optional error and stackTrace, and correlation identifiers.

Construction is cheap and allocation-aware: the constructor takes a pre-merged context rather than rebuilding it from layered sources, so the merging cost is paid once per event by the runtime, not per sink.

Annotations
  • @immutable

Constructors

LogEvent({required DateTime timestamp, required LogLevel level, required String message, required String loggerName, Object? error, StackTrace? stackTrace, LogContext context = LogContext.empty, List<String> tags = const <String>[], TraceContext? trace, SourceLocation? source, Duration? elapsed, String? isolateName})
Creates an event. Most callers should not invoke this directly; use the methods on AppLogger instead.
const

Properties

context → LogContext
Pre-merged structured context: logger defaults + scope + span + call site fields. The merge order is enforced by LoggerRuntime so this field can be trusted by sinks and formatters.
final
elapsed → Duration?
Wall-clock time spent inside an enclosing span, if any. null for non-span events.
final
error → Object?
Attached error, if any.
final
hashCode → int
The hash code for this object.
no setterinherited
isolateName → String?
Identifier of the isolate or thread that produced the event, when available. The runtime fills this in via an enricher; the field is here so it can be carried in a typed slot rather than buried in context.
final
level → LogLevel
Severity level. Never LogLevel.off.
final
loggerName → String
Fully-qualified name of the logger that emitted the event (app.auth, app.network.http, …).
final
message → String
Human-readable message. Should be a short, stable string — variables belong in context, not interpolated into the message.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
source → SourceLocation?
Source location captured at the call site, when enabled.
final
stackTrace → StackTrace?
Stack trace associated with error, if any.
final
tags → List<String>
Searchable, low-cardinality labels (network, db, auth, …). Tags are intentionally separate from context so filters and sinks can index them cheaply.
final
timestamp → DateTime
Wall-clock time when the event was created.
final
trace → TraceContext?
Trace correlation, if a trace is active.
final

Methods

copyWith({DateTime? timestamp, LogLevel? level, String? message, String? loggerName, Object? error, StackTrace? stackTrace, LogContext? context, List<String>? tags, TraceContext? trace, SourceLocation? source, Duration? elapsed, String? isolateName, bool clearError = false, bool clearStackTrace = false, bool clearTrace = false, bool clearSource = false, bool clearElapsed = false, bool clearIsolateName = false}) → LogEvent
Returns a copy with the listed fields replaced. Used by enrichers, redactors, and transformers in the pipeline.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
withExtraContext(Map<String, Object?> extras) → LogEvent
Returns a copy whose context has extras merged on top.
withExtraTags(Iterable<String> extra) → LogEvent
Returns a copy whose tags include the additional extra entries.

Operators

operator ==(Object other) → bool
The equality operator.
inherited