Struct InstrumentsAccessor
Lightweight zero-allocation facade over an IInstrumentsSink for logging and tracing. All formatting is skipped when the sink is disabled for the given scope and level.
public readonly struct InstrumentsAccessor
- Inherited Members
- Extension Methods
Constructors
InstrumentsAccessor(IInstrumentsSink?)
Initializes a new accessor backed by the given sink.
public InstrumentsAccessor(IInstrumentsSink? sink)
Parameters
sinkIInstrumentsSinkThe sink to write to, or
nullto produce a no-op accessor.
Methods
Log(Scope, LevelOfDetail, ref InstrumentsInterpolatedStringHandler)
Logs a formatted message at the given scope and level of detail.
public void Log(Scope scope, LevelOfDetail lod, ref InstrumentsInterpolatedStringHandler message)
Parameters
scopeScopeThe instrumentation scope.
lodLevelOfDetailThe level of detail for filtering.
messageInstrumentsInterpolatedStringHandlerThe interpolated message string. Not evaluated when the sink is disabled.
Trace(Scope, LevelOfDetail, ref InstrumentsInterpolatedStringHandler)
Begins a named trace scope and returns a TraceScope that ends it when disposed.
public TraceScope Trace(Scope scope, LevelOfDetail lod, ref InstrumentsInterpolatedStringHandler message)
Parameters
scopeScopeThe instrumentation scope.
lodLevelOfDetailThe level of detail for filtering.
messageInstrumentsInterpolatedStringHandlerThe interpolated trace label. Not evaluated when the sink is disabled.
Returns
- TraceScope
A TraceScope that calls EndTrace() on dispose.