Skip to content

Commit

Permalink
add repro for #1563
Browse files Browse the repository at this point in the history
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Sep 14, 2021
1 parent c24621f commit 3537afb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions tracing-subscriber/tests/layer_filters/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mod support;
use self::support::*;
mod filter_scopes;
mod targets;
mod trees;

use tracing::{level_filters::LevelFilter, Level};
Expand Down
42 changes: 42 additions & 0 deletions tracing-subscriber/tests/layer_filters/targets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use super::*;

use log::*;
use std::str::FromStr;
use tracing_subscriber::{
filter::{filter_fn, Targets},
prelude::*,
};

#[test]
fn default_debug() -> Result<(), std::io::Error> {
// Reproduces https://github.com/tokio-rs/tracing/issues/1563

mod inner {
use super::*;

#[tracing::instrument]
pub fn events(yak: u32) {
debug!("inner - yak: {} - this is debug", yak);
info!("inner - yak: {} - this is info", yak);
warn!("inner - yak: {} - this is warn", yak);
}
}

let filter = Targets::from_str("debug,layer_filters::targets::inner=warn").unwrap();

let fmt_layer =
tracing_subscriber::layer::Identity::new().with_filter(filter_fn(move |_meta| true));

tracing_subscriber::registry()
.with(filter)
.with(fmt_layer)
.init();

debug!("before inner");

inner::events(11111);

debug!("after inner");

Ok(())
}

0 comments on commit 3537afb

Please sign in to comment.