Open mdecimus opened 3 months ago
The following also does not work:
Registry::default().with(EnvFilter::builder().parse(format!("crate1=INFO,crate2=DEBUG,crate3=INFO")).unwrap())
.with(layers)
Update:
I found a different approach that works:
let mut layers: Option<Box<dyn Layer<Registry> + Sync + Send>> = None;
loop {
let layer = // Create layer;
layers = Some(match layers {
Some(layers) => layers.and_then(new_layer).boxed(),
None => layer,
});
}
tracing_subscriber::registry().with(layers.expect("no layers found")).init()
I am leaving this open anyway in case the issue described above is a bug with EnvFilters and boxed layers.
Bug Report
Version
Platform
Darwin local22.6.0 Darwin Kernel Version 22.6.0
Description
I need to dynamically create layers for different logging mechanisms. I found out that
EnvFilter
does not work (i.e. no logging at all is done) when aVec<Box<dyn Layer>>
is used.For example,
The problem seems related to passing the layer inside a
Vec
because the following code does produce log events: