tracing_subscriber/filter/
mod.rs

1//! [`Layer`]s that control which spans and events are enabled by the wrapped
2//! subscriber.
3//!
4//! This module contains a number of types that provide implementations of
5//! various strategies for filtering which spans and events are enabled. For
6//! details on filtering spans and events using [`Layer`]s, see the
7//! [`layer` module's documentation].
8//!
9//! [`layer` module's documentation]: crate::layer#filtering-with-layers
10//! [`Layer`]: crate::layer
11mod filter_fn;
12
13feature! {
14    #![all(feature = "env-filter", feature = "std")]
15    mod env;
16    pub use self::env::*;
17}
18
19feature! {
20    #![all(feature = "registry", feature = "std")]
21    mod layer_filters;
22    pub use self::layer_filters::*;
23}
24
25mod level;
26
27pub use self::filter_fn::*;
28pub use self::level::{LevelFilter, ParseError as LevelParseError};
29
30#[cfg(not(all(feature = "registry", feature = "std")))]
31pub(crate) use self::has_plf_stubs::*;
32
33feature! {
34    #![any(feature = "std", feature = "alloc")]
35    pub mod targets;
36    pub use self::targets::Targets;
37
38    mod directive;
39    pub use self::directive::ParseError;
40}
41
42/// Stub implementations of the per-layer-filter detection functions for when the
43/// `registry` feature is disabled.
44#[cfg(not(all(feature = "registry", feature = "std")))]
45mod has_plf_stubs {
46    pub(crate) fn is_plf_downcast_marker(_: core::any::TypeId) -> bool {
47        false
48    }
49
50    /// Does a type implementing `Subscriber` contain any per-layer filters?
51    pub(crate) fn subscriber_has_plf<S>(_: &S) -> bool
52    where
53        S: tracing_core::Subscriber,
54    {
55        false
56    }
57
58    /// Does a type implementing `Layer` contain any per-layer filters?
59    pub(crate) fn layer_has_plf<L, S>(_: &L) -> bool
60    where
61        L: crate::Layer<S>,
62        S: tracing_core::Subscriber,
63    {
64        false
65    }
66}