Expand description
Injectable EffectLogger service for the effect system.
§Service/Tag pattern
Extract the logger from the environment once with require!(EffectLogger), then call
its methods as regular effectful steps:
ⓘ
effect!(|_r: &mut R| {
let logger = require!(EffectLogger);
~logger.warn("something suspicious");
~logger.info("all good");
result
})The environment R only needs to satisfy
R: Get<EffectLogger, Here, Target = EffectLogger>. The caller composes
layers at the top of the program. For a minimal stack that only provides
EffectLogger, build Context::new(Cons(layer_effect_logger().build().expect(\"…\"), Nil))
or Context::new(Cons(Service::<EffectLogger, _>::new(EffectLogger), Nil)) at the program edge.
Log methods accept impl Into<Cow<'static, str>>: literals stay zero-copy;
runtime text passes as String or format!(...).
Structs§
- Composite
LogBackend - Thread-safe list of backends; also implements
LogBackendby fan-out. - Effect
LogComposite - Marker capability: composite log backend installed on this thread.
- Effect
LogMetadata - Marker capability: fiber-local log annotation / span metadata installed.
- Effect
Logger - Log sink registered as
EffectLoggervia capability DI; forwards totracing. - Effect
Logger Live - Default
EffectLoggerprovider (tracing-backed). - Json
LogBackend - One JSON object per line (
serde_json), for files or test buffers. - LogContext
- Metadata attached to log lines (wall-clock UTC, etc.).
- LogMetadata
Live - Installs fiber-local annotation and span-stack refs used by
crate::annotate_logsandcrate::with_log_span. - LogRecord
- One log event passed to each backend in a
CompositeLogBackend. - Structured
LogBackend - Human-oriented
key=valuelines (no JSON), still machine-grep-friendly. - Tracing
LogBackend - Forwards to the
tracingcrate (same levels ascrate::EffectLoggerlegacy path).
Enums§
- Effect
Logger Error - Errors that a log sink may produce.
- LogLevel
- Logging level for
EffectLogger.
Traits§
- LogBackend
- Sink for
LogRecordvalues (tracing, JSON file, tests, etc.). - Logger
- Effect.ts-style composable logger:
Self::add,Self::replace,Self::remove.
Functions§
- annotate_
logs - Run
innerwithkey=valuemerged into the fiber-local annotation map (restored afterward). - provide_
composite_ logger - Build a provider that registers
compositeforEffectLogger::logon this thread. - provide_
minimum_ log_ level - Build a provider that allocates a minimum
LogLevelFiberRefand registers it for filtering. - with_
log_ span - Run
innerwhile a span label is pushed on the fiber-local span stack (restored afterward).
Type Aliases§
- Effect
LogMin Level - Fiber-local minimum log level installed by
provide_minimum_log_level.