pub struct Filter { /* private fields */ }Available on crate feature
std only.Expand description
A target-aware severity gate.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn new(default_level: Level) -> Self
pub fn new(default_level: Level) -> Self
New filter with a default minimum severity and no overrides.
Sourcepub fn with_rule(self, target: impl Into<String>, level: Level) -> Self
pub fn with_rule(self, target: impl Into<String>, level: Level) -> Self
Add a per-target override. Rules are checked in insertion order; the longest, most specific prefix should be added first.
Sourcepub fn default_level(&self) -> Level
pub fn default_level(&self) -> Level
The configured default severity.
Sourcepub fn rules(&self) -> &[FilterRule]
pub fn rules(&self) -> &[FilterRule]
The configured rules in insertion order.
Sourcepub fn is_enabled(&self, target: &str, level: Level) -> bool
pub fn is_enabled(&self, target: &str, level: Level) -> bool
Decide whether a record at level/target should be admitted.
Returns true when the level is at least as severe as the rule
matched (or the default, if no rule matches).
Sourcepub fn threshold_for(&self, target: &str) -> Level
pub fn threshold_for(&self, target: &str) -> Level
Return the configured threshold for a target.
Sourcepub fn parse(directive: &str) -> Result<Self, ParseFilterError>
pub fn parse(directive: &str) -> Result<Self, ParseFilterError>
Parse a directive string like info,app::auth=debug,hyper=warn.
Whitespace is trimmed. Unknown levels return an error.
§Errors
Returns ParseFilterError if any segment fails to parse as
Level or target=Level.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnsafeUnpin for Filter
impl UnwindSafe for Filter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more