-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |