1 | use tracing_core::{ |
2 | callsite::Callsite, |
3 | metadata, |
4 | metadata::{Kind, Level, Metadata}, |
5 | subscriber::Interest, |
6 | }; |
7 | |
8 | #[test] |
9 | fn metadata_macro_api() { |
10 | // This test should catch any inadvertent breaking changes |
11 | // caused by changes to the macro. |
12 | struct TestCallsite; |
13 | |
14 | impl Callsite for TestCallsite { |
15 | fn set_interest(&self, _: Interest) { |
16 | unimplemented!("test" ) |
17 | } |
18 | fn metadata(&self) -> &Metadata<'_> { |
19 | unimplemented!("test" ) |
20 | } |
21 | } |
22 | |
23 | static CALLSITE: TestCallsite = TestCallsite; |
24 | let _metadata = metadata! { |
25 | name: "test_metadata" , |
26 | target: "test_target" , |
27 | level: Level::DEBUG, |
28 | fields: &["foo" , "bar" , "baz" ], |
29 | callsite: &CALLSITE, |
30 | kind: Kind::SPAN, |
31 | }; |
32 | let _metadata = metadata! { |
33 | name: "test_metadata" , |
34 | target: "test_target" , |
35 | level: Level::TRACE, |
36 | fields: &[], |
37 | callsite: &CALLSITE, |
38 | kind: Kind::EVENT, |
39 | }; |
40 | let _metadata = metadata! { |
41 | name: "test_metadata" , |
42 | target: "test_target" , |
43 | level: Level::INFO, |
44 | fields: &[], |
45 | callsite: &CALLSITE, |
46 | kind: Kind::EVENT |
47 | }; |
48 | } |
49 | |