I use tracing, and I only want to see my own debug events. However, some crates I depend on also have tracing support, and they litter the event stream. So when I increase verbosity to DEBUG
, I see a lot of these in my logs:
2022-08-04T20:52:24.523161Z DEBUG hyper::proto::h1::io: flushed 1008 bytes
I tried to turn off these events by adding spans around such calls:
let response = {
let span = tracing::info_span!("my_span");
let _guard = span.enter();
client
// set up the request
.send()
.await
};
I expected those 3rd party DEBUG
events to go away since the span's verbosity level is INFO
. But they remained. The docs of spans is a little light on what the verbosity level of a span really means, so my interpretation might be totally off.
How do I set the verbosity level for dependent crates, so only my own DEBUG
events appear in the trace logs?
I set the verbosity level using the environment variable RUST_LOG=debug
, and I set up tracing-subscriber like this:
tracing_subscriber::fmt::init();
Relevant part of Cargo.toml
:
tracing = "0.1.36"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }