pub struct FilterDirectives { /* private fields */ }Expand description
A parsed set of per-module thresholds.
§Examples
use ash_log::*;
let filter = FilterDirectives::parse("info,my_app::db=trace,hyper=warn");
assert_eq!(filter.level_for("my_app::db::pool"), AuditSeverity::Trace);
assert_eq!(filter.level_for("hyper::client"), AuditSeverity::Warning);
assert_eq!(filter.level_for("anything_else"), AuditSeverity::Info);Implementations§
Source§impl FilterDirectives
impl FilterDirectives
Sourcepub fn parse(directives: &str) -> Self
pub fn parse(directives: &str) -> Self
Parse a RUST_LOG-style directive string.
Comma-separated entries, each either a bare level (the default for
every module) or target=level. Unparseable entries are skipped rather
than failing the whole string: a typo in one directive must not silence
the logger entirely.
Sourcepub fn from_env(var: &str) -> Self
pub fn from_env(var: &str) -> Self
Read directives from an environment variable.
Returns an empty filter if the variable is unset, which admits everything the logger’s own threshold admits.
Sourcepub fn level_for(&self, module: &str) -> AuditSeverity
pub fn level_for(&self, module: &str) -> AuditSeverity
The threshold for module, falling back to Trace when nothing matches
and no default was given — the filter then defers entirely to the
logger’s own level.
Sourcepub fn has_default(&self) -> bool
pub fn has_default(&self) -> bool
Whether a default level was specified.
Sourcepub fn directives(&self) -> &[Directive]
pub fn directives(&self) -> &[Directive]
The parsed directives, most specific first.
Trait Implementations§
Source§impl Clone for FilterDirectives
impl Clone for FilterDirectives
Source§impl Debug for FilterDirectives
impl Debug for FilterDirectives
Auto Trait Implementations§
impl Forget for FilterDirectives
impl Freeze for FilterDirectives
impl Move for FilterDirectives
impl RefUnwindSafe for FilterDirectives
impl Send for FilterDirectives
impl Sync for FilterDirectives
impl Unpin for FilterDirectives
impl UnsafeUnpin for FilterDirectives
impl UnwindSafe for FilterDirectives
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