pub struct ModuleFilters { /* private fields */ }Expand description
Module-level log filters.
This struct manages log level filters on a per-module basis, allowing fine-grained control over which modules should log at which levels.
Filters are checked from most specific to least specific:
- Exact module path match (e.g.,
my_crate::module::submodule) - Prefix match (e.g.,
my_crate::modulematchesmy_crate::module::*) - Global default level
Implementations§
Source§impl ModuleFilters
impl ModuleFilters
Sourcepub fn new(default_level: LevelFilter) -> Self
pub fn new(default_level: LevelFilter) -> Self
Create a new ModuleFilters with a default level.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Parse RUST_LOG environment variable format.
Supports formats like:
debug- Set default level to debugmy_crate=debug- Set specific module to debugmy_crate::module=trace,warn- Multiple filters separated by commamy_crate=debug,other_crate::module=trace- Multiple module filters
Sourcepub fn add_filter(&mut self, module: impl Into<String>, level: LevelFilter)
pub fn add_filter(&mut self, module: impl Into<String>, level: LevelFilter)
Add a filter for a specific module.
Sourcepub fn level_for(&self, module_path: &str) -> LevelFilter
pub fn level_for(&self, module_path: &str) -> LevelFilter
Get the log level for a specific module path.
This checks in order:
- Exact match for the module path
- Prefix matches (from most specific to least specific)
- Default level
Sourcepub fn default_level(&self) -> LevelFilter
pub fn default_level(&self) -> LevelFilter
Get the default level.
Sourcepub fn set_default_level(&mut self, level: LevelFilter)
pub fn set_default_level(&mut self, level: LevelFilter)
Set the default level.
Trait Implementations§
Source§impl Clone for ModuleFilters
impl Clone for ModuleFilters
Source§fn clone(&self) -> ModuleFilters
fn clone(&self) -> ModuleFilters
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModuleFilters
impl Debug for ModuleFilters
Auto Trait Implementations§
impl Freeze for ModuleFilters
impl RefUnwindSafe for ModuleFilters
impl Send for ModuleFilters
impl Sync for ModuleFilters
impl Unpin for ModuleFilters
impl UnwindSafe for ModuleFilters
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