1 | #![cfg (feature = "std" )] |
2 | |
3 | use tracing_mock::*; |
4 | use tracing_subscriber::prelude::*; |
5 | |
6 | #[test] |
7 | fn init_ext_works() { |
8 | let (subscriber, finished) = subscriber::mock() |
9 | .event( |
10 | expect::event() |
11 | .at_level(tracing::Level::INFO) |
12 | .with_target("init_works" ), |
13 | ) |
14 | .only() |
15 | .run_with_handle(); |
16 | |
17 | let _guard = subscriber.set_default(); |
18 | tracing::info!(target: "init_works" , "it worked!" ); |
19 | finished.assert_finished(); |
20 | } |
21 | |
22 | #[test] |
23 | #[cfg (feature = "fmt" )] |
24 | fn builders_are_init_ext() { |
25 | tracing_subscriber::fmt().set_default(); |
26 | let _ = tracing_subscriber::fmt() |
27 | .with_target(false) |
28 | .compact() |
29 | .try_init(); |
30 | } |
31 | |
32 | #[test] |
33 | #[cfg (all(feature = "fmt" , feature = "env-filter" ))] |
34 | fn layered_is_init_ext() { |
35 | tracing_subscriber::registry() |
36 | .with(tracing_subscriber::fmt::layer()) |
37 | .with(tracing_subscriber::EnvFilter::new("foo=info" )) |
38 | .set_default(); |
39 | } |
40 | |