Struct env_logger::filter::Builder

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

A builder for a log filter.

It can be used to parse a set of directives from a string before building a Filter instance.

Example

use env_logger::filter::Builder;

let mut builder = Builder::new();

// Parse a logging filter from an environment variable.
if let Ok(rust_log) = env::var("RUST_LOG") {
    builder.parse(&rust_log);
}

let filter = builder.build();

Implementations§

source§

impl Builder

source

pub fn new() -> Builder

Initializes the filter builder with defaults.

source

pub fn from_env(env: &str) -> Builder

Initializes the filter builder from an environment.

source

pub fn filter_module(&mut self, module: &str, level: LevelFilter) -> &mut Self

Adds a directive to the filter for a specific module.

source

pub fn filter_level(&mut self, level: LevelFilter) -> &mut Self

Adds a directive to the filter for all modules.

source

pub fn filter(&mut self, module: Option<&str>, level: LevelFilter) -> &mut Self

Adds a directive to the filter.

The given module (if any) will log at most the specified level provided. If no module is provided then the filter will apply to all log messages.

source

pub fn parse(&mut self, filters: &str) -> &mut Self

Parses the directives string.

See the Enabling Logging section for more details.

source

pub fn build(&mut self) -> Filter

Build a log filter.

Trait Implementations§

source§

impl Debug for Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Builder

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.