Struct android_logger::Filter
source · pub struct Filter { /* private fields */ }
Expand description
Filter for android logger.
Implementations
sourceimpl Filter
impl Filter
sourcepub fn with_min_level(self, level: Level) -> Self
pub fn with_min_level(self, level: Level) -> Self
Change the minimum log level.
All values above the set level are logged. For example, if
Warn
is set, the Error
is logged too, but Info
isn’t.
sourcepub fn with_allowed_module_path<S: Into<String>>(self, path: S) -> Self
pub fn with_allowed_module_path<S: Into<String>>(self, path: S) -> Self
Set allowed module path.
Allow log entry only if module path matches specified path exactly.
Example:
use android_logger::Filter;
let filter = Filter::default().with_allowed_module_path("crate");
assert!(filter.is_module_path_allowed("crate"));
assert!(!filter.is_module_path_allowed("other_crate"));
assert!(!filter.is_module_path_allowed("crate::subcrate"));
Multiple rules example:
use android_logger::Filter;
let filter = Filter::default()
.with_allowed_module_path("A")
.with_allowed_module_path("B");
assert!(filter.is_module_path_allowed("A"));
assert!(filter.is_module_path_allowed("B"));
assert!(!filter.is_module_path_allowed("C"));
assert!(!filter.is_module_path_allowed("A::B"));
sourcepub fn with_allowed_module_paths<I: IntoIterator<Item = String>>(
self,
paths: I
) -> Self
pub fn with_allowed_module_paths<I: IntoIterator<Item = String>>(
self,
paths: I
) -> Self
Set multiple allowed module paths.
Same as with_allowed_module_path
, but accepts list of paths.
Example:
use android_logger::Filter;
let filter = Filter::default()
.with_allowed_module_paths(["A", "B"].iter().map(|i| i.to_string()));
assert!(filter.is_module_path_allowed("A"));
assert!(filter.is_module_path_allowed("B"));
assert!(!filter.is_module_path_allowed("C"));
assert!(!filter.is_module_path_allowed("A::B"));
sourcepub fn is_module_path_allowed(&self, path: &str) -> bool
pub fn is_module_path_allowed(&self, path: &str) -> bool
Check if module path is allowed by filter rules.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more