logo
 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! [`Layer`]s that control which spans and events are enabled by the wrapped
//! subscriber.
//!
//! This module contains a number of types that provide implementations of
//! various strategies for filtering which spans and events are enabled. For
//! details on filtering spans and events using [`Layer`]s, see the
//! [`layer` module's documentation].
//!
//! [`layer` module's documentation]: crate::layer#filtering-with-layers
//! [`Layer`]: crate::layer
mod directive;
#[cfg(feature = "env-filter")]
mod env;
mod filter_fn;
#[cfg(feature = "registry")]
mod layer_filters;
mod level;
pub mod targets;

pub use self::directive::ParseError;
pub use self::filter_fn::*;
#[cfg(not(feature = "registry"))]
pub(crate) use self::has_plf_stubs::*;

#[cfg(feature = "registry")]
#[cfg_attr(docsrs, doc(cfg(feature = "registry")))]
pub use self::layer_filters::*;
pub use self::level::{LevelFilter, ParseError as LevelParseError};

#[cfg(feature = "env-filter")]
#[cfg_attr(docsrs, doc(cfg(feature = "env-filter")))]
pub use self::env::*;

pub use self::targets::Targets;

/// Stub implementations of the per-layer-fitler detection functions for when the
/// `registry` feature is disabled.
#[cfg(not(feature = "registry"))]
mod has_plf_stubs {
    pub(crate) fn is_plf_downcast_marker(_: std::any::TypeId) -> bool {
        false
    }

    /// Does a type implementing `Subscriber` contain any per-layer filters?
    pub(crate) fn subscriber_has_plf<S>(_: &S) -> bool
    where
        S: tracing_core::Subscriber,
    {
        false
    }

    /// Does a type implementing `Layer` contain any per-layer filters?
    pub(crate) fn layer_has_plf<L, S>(_: &L) -> bool
    where
        L: crate::Layer<S>,
        S: tracing_core::Subscriber,
    {
        false
    }
}