You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I write a program that configures a typical tracing subscriber (just using the types from tracing-subscriber) while also using tracing_log::LogTracer to capture log messages from a dependency?
I tried the following minimal code:
use tracing_subscriber::filter::LevelFilter;fnmain(){
tracing_log::LogTracer::init().unwrap();
tracing_subscriber::fmt().with_max_level(LevelFilter::TRACE).init();
log::debug!("This is a log message.");
tracing::debug!("This is a tracing message.");}
thread 'main' panicked at /Users/jwodder/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-subscriber-0.3.18/src/fmt/mod.rs:517:14:
Unable to install global subscriber: SetLoggerError(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Switching the order of the init()'s just changes the error to:
thread 'main' panicked at src/main.rs:7:36:
called `Result::unwrap()` on an `Err` value: SetLoggerError(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How can I write a program that configures a typical tracing subscriber (just using the types from
tracing-subscriber
) while also usingtracing_log::LogTracer
to capturelog
messages from a dependency?I tried the following minimal code:
on Rust 1.76 with these dependencies:
but it fails with:
Switching the order of the
init()
's just changes the error to:Beta Was this translation helpful? Give feedback.
All reactions