Skip to main content

Builder

Struct 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_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_component( &mut self, component: &str, level: LevelFilter, negated: bool, ) -> &mut Self

Adds a component directive to the filter.

Source

pub fn filter_topic( &mut self, component: &str, topic: &str, level: LevelFilter, negated: bool, ) -> &mut Self

Adds a component + topic directive to the filter.

Source

pub fn filter_key_value( &mut self, key: &str, value: &str, negated: bool, ) -> &mut Self

Adds a key/value filter to the overall filter.

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 try_parse(&mut self, filters: &str) -> Result<&mut Self, ParseError>

Parses the directive string, returning an error if the given directive string is invalid.

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.