-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to modify EnvFilter instead of replace #3025
Comments
Could you post a snippet? Also checkout https://docs.rs/tracing-subscriber/latest/tracing_subscriber/reload/index.html#examples. This should be possible if I understand your issue correctly. |
@kaffarell I use the envfilter. Because of it can easy to "and" tow filter. I use one global level filter and some target filter in a env filter. // trace init:
let subscriber = tracing_fmt::fmt()
.with_timer(tracing_fmt::time::LocalTime::rfc_3339())
.with_file(true)
.with_line_number(true)
.with_writer(non_blocking)
.with_ansi(false)
.with_env_filter(format!("info,sys_monitor::event_trace::stack_walk=debug")) // env filter
.with_filter_reloading();
let reload_handle = subscriber.reload_handle();
subscriber.init();
//==================
// How to modify env filter like this:
reload_handle.modify(|filter| *filter = filter::LevelFilter::DEBUG); |
AFAIK editing the let filter = filter::LevelFilter::WARN;
let (filter, reload_handle) = reload::Layer::new(filter);
let layer = tracing_subscriber::fmt::layer()
.with_timer(tracing_subscriber::fmt::time::LocalTime::rfc_3339())
.with_file(true)
.with_line_number(true)
.with_ansi(false)
.with_filter(EnvFilter::new("trace,sys_monitor::event_trace::stack_walk=debug"))
.with_filter(filter);
tracing_subscriber::registry().with(layer).init();
let _ = reload_handle.modify(|filter| *filter = filter::LevelFilter::DEBUG); |
in tracing_subscriber 0.3.18
I use a Envfilter in global subscriber. It is composed of one LevelFilter and Targets. When i modify the level filter, i need replace the entire EnvFilter. How do I only modify the LevelFilter in EnvFilter.
The text was updated successfully, but these errors were encountered: