pub struct LogSpecBuilder { /* private fields */ }
Expand description

Builder for LogSpecification.

§Example

Start with a programmatically built log specification, and use the LoggerHandle to apply a modified version of the log specification at a later point in time:

use flexi_logger::{Logger, LogSpecification};
use log::LevelFilter;

fn main() {
    // Build the initial log specification
    let mut builder = LogSpecification::builder();
    builder
        .default(LevelFilter::Info)
        .module("karl", LevelFilter::Debug);

    // Initialize Logger, keep builder alive
    let mut logger = Logger::with(builder.build())
        // your logger configuration goes here, as usual
        .start()
        .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));

    // ...

    // Modify builder and update the logger
    builder
        .default(LevelFilter::Error)
        .remove("karl")
        .module("emma", LevelFilter::Trace);

    logger.set_new_spec(builder.build());

    // ...
}

Implementations§

source§

impl LogSpecBuilder

source

pub fn new() -> Self

Creates a LogSpecBuilder with all logging turned off.

source

pub fn from_module_filters(module_filters: &[ModuleFilter]) -> Self

Creates a LogSpecBuilder from given module filters.

source

pub fn default(&mut self, lf: LevelFilter) -> &mut Self

Adds a default log level filter, or updates the default log level filter.

source

pub fn module<M: AsRef<str>>( &mut self, module_name: M, lf: LevelFilter ) -> &mut Self

Adds a log level filter, or updates the log level filter, for a module.

source

pub fn remove<M: AsRef<str>>(&mut self, module_name: M) -> &mut Self

Adds a log level filter, or updates the log level filter, for a module.

source

pub fn insert_modules_from(&mut self, other: LogSpecification) -> &mut Self

Adds log level filters from a LogSpecification.

source

pub fn finalize(self) -> LogSpecification

Creates a log specification without text filter.

source

pub fn finalize_with_textfilter(self, tf: Regex) -> LogSpecification

Creates a log specification with text filter.

This method is only avaible if the dafault feature textfilter is not switched off.

source

pub fn build(&self) -> LogSpecification

Creates a log specification without being consumed.

source

pub fn build_with_textfilter(&self, tf: Option<Regex>) -> LogSpecification

Available on crate feature textfilter only.

Creates a log specification without being consumed, optionally with a text filter.

This method is only avaible if the dafault feature textfilter is not switched off.

Trait Implementations§

source§

impl Clone for LogSpecBuilder

source§

fn clone(&self) -> LogSpecBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LogSpecBuilder

source§

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

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

impl Default for LogSpecBuilder

source§

fn default() -> LogSpecBuilder

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more