mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-09-30 06:20:38 +00:00

This branch adds `tokio-trace-log` and `tokio-trace-env-logger` compatibility crates which can be used to bring log records emitted by crates using the `log` library into the context of a trace. Loggers are provided which implement the `log::Log` trait by converting log records into events in the span that is executing when the record is logged, and propagates them to the trace dispatcher. This conversion is not capable of parsing unstructured log messages and converting them into a structured format (as this would require some form of natural-language processing to implement correctly), but allows log records to be placed within the context of a span. This is useful as a migration path for codebases which already use unstructured logging, and as a way for codebases using `tokio-trace` to to connect the log records emitted by dependencies with the tracing system without requiring upstream code changes. * Event metadata need not be 'static, so it can be generated from log meta * first pass on an adapter for the log crate * add doc to log adapter * feature-flag env-logger compat and move it to a module * actually, just put env-logger compat in a separate crate feature flags are more confusing for downstream users. * improve log compat crate docs * remove unneeded deps from tokio-trace-log Cargo.toml * document Event lifetime parameters