LogController class
Central log dispatcher.
Owns the processing pipeline: filter -> sample -> enrich -> redact -> route to outputs. Created by the user, injected into endpoints.
Constructors
-
LogController({RpcLogLevel minLevel = RpcLogLevel.debug, bool spansEnabled = true, DateTime clock()?, List<
LogOutput> outputs = const [], List<LogEnricher> enrichers = const [], SamplingConfig? sampling, LogRedactor? redactor, String? ambientParent()?}) - Creates a LogController with optional outputs, enrichers, and filters.
Properties
- ambientParent → String? Function()?
-
The span of the work running now, as a W3C
traceparent, for a span that has no parent, no trace of its own and no remote parent: it becomes that span's child (an RPC span an interceptor opened, so its ids are the ones a remote child must name). Null, or answering null: such a span starts a trace of its own.rpc_dart_opentelemetry'sotelTraceparentreads the OTel context.final - clock → DateTime Function()
-
Clock function used for timestamps. Defaults to DateTime.now.
Override in tests for deterministic timestamps.
final
- config → LogConfig
-
Current configuration snapshot (for remote control / diagnostics).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasSinks → bool
-
Whether anything takes records now: an output, or a listener of
stream. Asked at every record, so an output added later, or a
listener, is served from then on; a span started while there was
none stays a no-op span.
no setter
- minLevel ↔ RpcLogLevel
-
Global minimum log level. Records below this are discarded.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spansEnabled ↔ bool
-
Whether spans are emitted. Defaults to true.
Spans bypass level filtering (they are telemetry, not log messages),
but can be disabled entirely via this flag.
getter/setter pair
-
stream
→ Stream<
LogRecord> -
Broadcast stream of records that passed all filters.
no setter
Methods
-
accepts(
RpcLogLevel level, String scope, [String? tag]) → bool -
Quick check whether a record at
levelfromscopewould pass filtering. Used by LogScope guards (isTrace, isInternal) and pre-filter in _log(). -
add(
LogRecord record) → void - Submit a log record to the pipeline. Synchronous, non-blocking.
-
addEnricher(
LogEnricher enricher) → void - Add an enricher to the pipeline at runtime.
-
addOutput(
LogOutput output) → void - Add an output to the pipeline at runtime.
-
clearScopeLevel(
String scope) → void - Remove scope-specific level override.
-
clearTagLevel(
String tag) → void - Remove tag-specific level override.
-
dispose(
) → void - Dispose all outputs and close the record stream.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeEnricher(
LogEnricher enricher) → void - Remove an enricher from the pipeline at runtime.
-
removeOutput(
LogOutput output) → void - Remove an output from the pipeline at runtime.
-
scope(
String name, {String? tag}) → LogScope - Create a scoped logger bound to this controller.
-
setRedactor(
LogRedactor? redactor) → void - Replace the redactor at runtime. Pass null to disable redaction.
-
setScopeLevel(
String scope, RpcLogLevel level) → void - Set minimum level for a specific scope prefix.
-
setTagLevel(
String tag, RpcLogLevel level) → void - Set minimum level for a specific tag.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited