simplelog

Struct ConfigBuilder

Source
#[non_exhaustive]
pub struct ConfigBuilder(/* private fields */);
Expand description

Builder for the Logger Configurations (Config)

All loggers print the message in the following form: 00:00:00 [LEVEL] crate::module: [lib.rs::100] your_message Every space delimited part except the actual message is optional.

Use this struct to create a custom Config changing when these information shall be logged. Every part can be enabled for a specific Level and is then automatically enable for all lower levels as well.

The Result is that the logging gets more detailed the more verbose it gets. E.g. to have one part shown always use Level::Error. But if you want to show the source line only on Trace use that.

Implementations§

Source§

impl ConfigBuilder

Source

pub fn new() -> ConfigBuilder

Create a new default ConfigBuilder

Source

pub fn set_max_level(&mut self, level: LevelFilter) -> &mut ConfigBuilder

Set at which level and above (more verbose) the level itself shall be logged (default is Error)

Source

pub fn set_time_level(&mut self, time: LevelFilter) -> &mut ConfigBuilder

Set at which level and above (more verbose) the current time shall be logged (default is Error)

Source

pub fn set_thread_level(&mut self, thread: LevelFilter) -> &mut ConfigBuilder

Set at which level and above (more verbose) the thread id shall be logged. (default is Debug)

Source

pub fn set_target_level(&mut self, target: LevelFilter) -> &mut ConfigBuilder

Set at which level and above (more verbose) the target shall be logged. (default is Debug)

Source

pub fn set_location_level( &mut self, location: LevelFilter, ) -> &mut ConfigBuilder

Set at which level and above (more verbose) a source code reference shall be logged (default is Trace)

Source

pub fn set_level_padding(&mut self, padding: LevelPadding) -> &mut ConfigBuilder

Set how the levels should be padded, when logging (default is Off)

Source

pub fn set_thread_padding( &mut self, padding: ThreadPadding, ) -> &mut ConfigBuilder

Set how the thread should be padded

Source

pub fn set_thread_mode(&mut self, mode: ThreadLogMode) -> &mut ConfigBuilder

Set the mode for logging the thread

Source

pub fn set_level_color( &mut self, level: Level, color: Option<Color>, ) -> &mut ConfigBuilder

Set the color used for printing the level (if the logger supports it), or None to use the default foreground color

Source

pub fn set_time_format_str( &mut self, time_format: &'static str, ) -> &mut ConfigBuilder

Set time chrono strftime format string.

Source

pub fn set_time_format(&mut self, time_format: String) -> &mut ConfigBuilder

Set time chrono strftime format string.

Source

pub fn set_time_offset( &mut self, time_offset: FixedOffset, ) -> &mut ConfigBuilder

Set offset used for logging time (default is 0)

Source

pub fn set_time_to_local(&mut self, local: bool) -> &mut ConfigBuilder

set if you log in local timezone or UTC (default is UTC)

Source

pub fn add_filter_allow_str( &mut self, filter_allow: &'static str, ) -> &mut ConfigBuilder

Add allowed module filters. If any are specified, only records from modules starting with one of these entries will be printed

For example, add_filter_allow_str("tokio::uds") would allow only logging from the tokio crates uds module.

Source

pub fn add_filter_allow(&mut self, filter_allow: String) -> &mut ConfigBuilder

Add allowed module filters. If any are specified, only records from modules starting with one of these entries will be printed

For example, add_filter_allow(format!("{}{}","tokio", "uds")) would allow only logging from the tokio crates uds module.

Source

pub fn clear_filter_allow(&mut self) -> &mut ConfigBuilder

Clear allowed module filters. If none are specified, nothing is filtered out

Source

pub fn add_filter_ignore_str( &mut self, filter_ignore: &'static str, ) -> &mut ConfigBuilder

Add denied module filters. If any are specified, records from modules starting with one of these entries will be ignored

For example, add_filter_ignore_str("tokio::uds") would deny logging from the tokio crates uds module.

Source

pub fn add_filter_ignore(&mut self, filter_ignore: String) -> &mut ConfigBuilder

Add denied module filters. If any are specified, records from modules starting with one of these entries will be ignored

For example, add_filter_ignore(format!("{}{}","tokio", "uds")) would deny logging from the tokio crates uds module.

Source

pub fn clear_filter_ignore(&mut self) -> &mut ConfigBuilder

Clear ignore module filters. If none are specified, nothing is filtered

Source

pub fn build(&mut self) -> Config

Build new Config

Trait Implementations§

Source§

impl Clone for ConfigBuilder

Source§

fn clone(&self) -> ConfigBuilder

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 ConfigBuilder

Source§

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

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

impl Default for ConfigBuilder

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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>,

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.