pub struct LogBuilder { /* private fields */ }Expand description
Struct for building a new logger
Implementations§
Source§impl LogBuilder
impl LogBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of the LogBuilder
§Defaults
level-> The default level isInfoexclude-> No targets are excludedtime_format-> dd.mm.YY HH:MM:SSlog_target-> false
§Example
//! Example for initializing the logger with the LogBuilder
use log::{error, warn, info, debug, trace};
use loggify::LogBuilder;
/// The `LogBuilder` is used to set more logger options
/// This example will change the log level to Trace
/// and the printed time format to time only
fn main() {
LogBuilder::new()
.set_level(log::Level::Trace)
.set_time_format(String::from("%H:%M:%S"))
.build()
.unwrap();
error!("My error message");
warn!("My warn message");
info!("My info message");
debug!("My debug message");
trace!("My trace message");
}Sourcepub fn add_exclude(self, name: String) -> Self
pub fn add_exclude(self, name: String) -> Self
Adds a new target to exclude from logging
See the example exclude for usage
Sourcepub fn set_time_format(self, format: String) -> Self
pub fn set_time_format(self, format: String) -> Self
Sets the time format See https://docs.rs/chrono/0.4.6/chrono/format/strftime/index.html for supported escape sequences
Sourcepub fn set_log_target(self, state: bool) -> Self
pub fn set_log_target(self, state: bool) -> Self
Defines if the log target should be printed or not This option should be used to find out where a log comes from and what target to exclude from logging
Sourcepub fn disable_color(self) -> Self
pub fn disable_color(self) -> Self
Disables color output
Per default true
Sourcepub fn build(self) -> Result<(), SetLoggerError>
pub fn build(self) -> Result<(), SetLoggerError>
Creates a new logger
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogBuilder
impl RefUnwindSafe for LogBuilder
impl Send for LogBuilder
impl Sync for LogBuilder
impl Unpin for LogBuilder
impl UnsafeUnpin for LogBuilder
impl UnwindSafe for LogBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more