Struct simplelog::ConfigBuilder
source · [−]#[non_exhaustive]pub struct ConfigBuilder(_);
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
Create a new default ConfigBuilder
Set at which level and above (more verbose) the level itself shall be logged (default is Error)
Set at which level and above (more verbose) the current time shall be logged (default is Error)
Set at which level and above (more verbose) the thread id shall be logged. (default is Debug)
Set at which level and above (more verbose) the target shall be logged. (default is Debug)
Set how the thread should be padded
Set at which level and above (more verbose) a source code reference shall be logged (default is Trace)
Set how the levels should be padded, when logging (default is Off)
Set how the thread should be padded
Set the mode for logging the thread
Set the color used for printing the level (if the logger supports it), or None to use the default foreground color
pub fn set_time_format_custom(
&mut self,
time_format: &'static [FormatItem<'static>]
) -> &mut ConfigBuilder
pub fn set_time_format_custom(
&mut self,
time_format: &'static [FormatItem<'static>]
) -> &mut ConfigBuilder
Sets the time format to a custom representation.
The easiest way to satisfy the static lifetime of the argument is to directly use the
re-exported time::macros::format_description
macro.
Note: The default time format is “[hour]:[minute]:[second]”.
The syntax for the format_description macro can be found in the
time
crate book.
Usage
let config = ConfigBuilder::new()
.set_time_format_custom(format_description!("[hour]:[minute]:[second].[subsecond]"))
.build();
Set time format string to use rfc2822.
Set time format string to use rfc3339.
Set offset used for logging time (default is UTC)
Sets the offset used to the current local time offset
(overriding values previously set by ConfigBuilder::set_time_offset
).
This function may fail if the offset cannot be determined soundly.
This may be the case, when the program is multi-threaded by the time of calling this function.
One can opt-out of this behavior by setting RUSTFLAGS="--cfg unsound_local_offset"
.
Doing so is not recommended, completely untested and may cause unexpected segfaults.
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.
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.
Clear allowed module filters. If none are specified, nothing is filtered out
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.
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.
Clear ignore module filters. If none are specified, nothing is filtered
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more