Struct android_logger::Filter

source ·
pub struct Filter { /* private fields */ }
Expand description

Filter for android logger.

Implementations

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.

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"));

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"));

Check if module path is allowed by filter rules.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.