Skip to content

Commit 23441be

Browse files
authored
Merge pull request #300 from epage/other
feat(filter): Add a Logger decorator
2 parents 98abcf2 + 6c2ea80 commit 23441be

File tree

11 files changed

+940
-955
lines changed

11 files changed

+940
-955
lines changed

crates/env_filter/src/directive.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use log::Level;
2+
use log::LevelFilter;
3+
4+
#[derive(Debug)]
5+
pub(crate) struct Directive {
6+
pub(crate) name: Option<String>,
7+
pub(crate) level: LevelFilter,
8+
}
9+
10+
// Check whether a level and target are enabled by the set of directives.
11+
pub(crate) fn enabled(directives: &[Directive], level: Level, target: &str) -> bool {
12+
// Search for the longest match, the vector is assumed to be pre-sorted.
13+
for directive in directives.iter().rev() {
14+
match directive.name {
15+
Some(ref name) if !target.starts_with(&**name) => {}
16+
Some(..) | None => return level <= directive.level,
17+
}
18+
}
19+
false
20+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy