Skip to main content

init_logging

Function init_logging 

Source
pub fn init_logging(otel_layer: Option<BoxedLayer>)
Expand description

Installs the process-global structured logger: JSON output (pretty on an interactive TTY), level from resolve_log_level() — mirrors targets::typescript’s logger.ts. Correlation IDs are carried as a trace_id span field (see correlation_context) rather than pino’s per-record mixin, since tracing spans are the idiomatic Rust equivalent of that pattern. Field-level secret redaction isn’t automatic here; call sanitizer::sanitize before logging any user- or API-controlled JSON payload.

otel_layer is composed into the same subscriber when tracing export is enabled (see otel::build_layer), since tracing only allows a single global default subscriber — the two layers can’t be installed independently without one call overwriting the other. Call once, at process startup.