-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
32 lines (30 loc) · 998 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[cfg(test)]
mod tests {
use tracing::{event, instrument, span, subscriber, Level};
use tracing_proc_macros::traced_test;
use tracing_subscriber::FmtSubscriber;
#[test]
#[instrument]
fn test1() {
let fmt_subscriber = FmtSubscriber::new();
subscriber::with_default(fmt_subscriber, || {
event!(Level::INFO, "T1: INFO 1");
let span = span!(Level::INFO, "my_span");
let _guard = span.enter();
event!(Level::DEBUG, "T1: DEBUG 1");
drop(_guard);
event!(Level::DEBUG, "T1: DEBUG 2");
event!(Level::INFO, "T1: INFO 2");
});
}
#[traced_test(FmtSubscriber)]
fn test2() {
event!(Level::INFO, "T2: INFO 1");
let span = span!(Level::INFO, "my_span");
let _guard = span.enter();
event!(Level::DEBUG, "T2: DEBUG 1");
drop(_guard);
event!(Level::DEBUG, "T2: DEBUG 2");
event!(Level::INFO, "T2: INFO 2");
}
}