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
I have a crate where I am setting up tracing. I would like to allow the user to optionally specify RUST_LOG to configure the tracing. But by default I would like to have an EnvFilter of warn,my_crate=debug.
Proposal
My initial thoughts were to add support on the builder, via a new function with_default_directives(directives: Vec<Directive>) to parse multiple directives, and then convert the default_directive field to a Vec<Directive>.
example of how it could be used:
let filter = EnvFilter::builder().with_default_directives(vec![LevelFilter::WARN.into(), "my_crate=debug".parse()?).from_env_lossy();
or another possibility could be:
with_default_filter(env_filter: EnvFilter)
let filter = EnvFilter::builder().with_default_filter("warn,my_crate=debug".parse().unwrap()).from_env_lossy();
I am more than willing to make a contribution to add this if there is interest!
Alternatives
It's possible to do this without the new function. It just seems like a nice quality of life addition to the builder.
let filter = if std::env::var("RUST_LOG").is_ok(){EnvFilter::builder().from_env_lossy()}else{"warn,my_crate=debug".parse()?
};
P.S. I love the tokio-rs::tracing ecosystem. Thank you for all the dedication to such clean tooling!
The text was updated successfully, but these errors were encountered:
Feature Request
Crates
tracing_subscriber
specifically
tracing_subscriber::filter::Builder
Motivation
I have a crate where I am setting up tracing. I would like to allow the user to optionally specify
RUST_LOG
to configure the tracing. But by default I would like to have an EnvFilter ofwarn,my_crate=debug
.Proposal
My initial thoughts were to add support on the builder, via a new function
with_default_directives(directives: Vec<Directive>)
to parse multiple directives, and then convert thedefault_directive
field to aVec<Directive>
.example of how it could be used:
or another possibility could be:
with_default_filter(env_filter: EnvFilter)
I am more than willing to make a contribution to add this if there is interest!
Alternatives
It's possible to do this without the new function. It just seems like a nice quality of life addition to the builder.
P.S. I love the
tokio-rs::tracing
ecosystem. Thank you for all the dedication to such clean tooling!The text was updated successfully, but these errors were encountered: