Struct flexi_logger::LogSpecBuilder
source · [−]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
sourceimpl LogSpecBuilder
impl LogSpecBuilder
sourcepub fn from_module_filters(module_filters: &[ModuleFilter]) -> Self
pub fn from_module_filters(module_filters: &[ModuleFilter]) -> Self
Creates a LogSpecBuilder
from given module filters.
sourcepub fn default(&mut self, lf: LevelFilter) -> &mut Self
pub fn default(&mut self, lf: LevelFilter) -> &mut Self
Adds a default log level filter, or updates the default log level filter.
sourcepub fn module<M: AsRef<str>>(
&mut self,
module_name: M,
lf: LevelFilter
) -> &mut Self
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.
sourcepub fn remove<M: AsRef<str>>(&mut self, module_name: M) -> &mut Self
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.
sourcepub fn insert_modules_from(&mut self, other: LogSpecification) -> &mut Self
pub fn insert_modules_from(&mut self, other: LogSpecification) -> &mut Self
Adds log level filters from a LogSpecification
.
sourcepub fn finalize(self) -> LogSpecification
pub fn finalize(self) -> LogSpecification
Creates a log specification without text filter.
sourcepub fn finalize_with_textfilter(self, tf: Regex) -> LogSpecification
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.
sourcepub fn build(&self) -> LogSpecification
pub fn build(&self) -> LogSpecification
Creates a log specification without being consumed.
sourcepub fn build_with_textfilter(&self, tf: Option<Regex>) -> LogSpecification
pub fn build_with_textfilter(&self, tf: Option<Regex>) -> LogSpecification
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
sourceimpl Clone for LogSpecBuilder
impl Clone for LogSpecBuilder
sourcefn clone(&self) -> LogSpecBuilder
fn clone(&self) -> LogSpecBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for LogSpecBuilder
impl Debug for LogSpecBuilder
sourceimpl Default for LogSpecBuilder
impl Default for LogSpecBuilder
sourcefn default() -> LogSpecBuilder
fn default() -> LogSpecBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for LogSpecBuilder
impl Send for LogSpecBuilder
impl Sync for LogSpecBuilder
impl Unpin for LogSpecBuilder
impl UnwindSafe for LogSpecBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more