1 | use tracing_core::{ |
2 | subscriber::{Interest, Subscriber}, |
3 | Metadata, |
4 | }; |
5 | |
6 | #[allow (unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411 |
7 | pub use tracing_core::metadata::{LevelFilter, ParseLevelFilterError as ParseError}; |
8 | |
9 | // === impl LevelFilter === |
10 | |
11 | impl<S: Subscriber> crate::Layer<S> for LevelFilter { |
12 | fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { |
13 | if self >= metadata.level() { |
14 | Interest::always() |
15 | } else { |
16 | Interest::never() |
17 | } |
18 | } |
19 | |
20 | fn enabled(&self, metadata: &Metadata<'_>, _: crate::layer::Context<'_, S>) -> bool { |
21 | self >= metadata.level() |
22 | } |
23 | |
24 | fn max_level_hint(&self) -> Option<LevelFilter> { |
25 | Some(*self) |
26 | } |
27 | } |
28 | |