Skip to main content

Crate id_effect_logger

Crate id_effect_logger 

Source
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§

CompositeLogBackend
Thread-safe list of backends; also implements LogBackend by fan-out.
EffectLogComposite
Marker capability: composite log backend installed on this thread.
EffectLogMetadata
Marker capability: fiber-local log annotation / span metadata installed.
EffectLogger
Log sink registered as EffectLogger via capability DI; forwards to tracing.
EffectLoggerLive
Default EffectLogger provider (tracing-backed).
JsonLogBackend
One JSON object per line (serde_json), for files or test buffers.
LogContext
Metadata attached to log lines (wall-clock UTC, etc.).
LogMetadataLive
Installs fiber-local annotation and span-stack refs used by crate::annotate_logs and crate::with_log_span.
LogRecord
One log event passed to each backend in a CompositeLogBackend.
StructuredLogBackend
Human-oriented key=value lines (no JSON), still machine-grep-friendly.
TracingLogBackend
Forwards to the tracing crate (same levels as crate::EffectLogger legacy path).

Enums§

EffectLoggerError
Errors that a log sink may produce.
LogLevel
Logging level for EffectLogger.

Traits§

LogBackend
Sink for LogRecord values (tracing, JSON file, tests, etc.).
Logger
Effect.ts-style composable logger: Self::add, Self::replace, Self::remove.

Functions§

annotate_logs
Run inner with key=value merged into the fiber-local annotation map (restored afterward).
provide_composite_logger
Build a provider that registers composite for EffectLogger::log on this thread.
provide_minimum_log_level
Build a provider that allocates a minimum LogLevel FiberRef and registers it for filtering.
with_log_span
Run inner while a span label is pushed on the fiber-local span stack (restored afterward).

Type Aliases§

EffectLogMinLevel
Fiber-local minimum log level installed by provide_minimum_log_level.