Struct libpt_log::LoggerBuilder
source · pub struct LoggerBuilder { /* private fields */ }Expand description
Implementations§
source§impl LoggerBuilder
impl LoggerBuilder
sourcepub fn build(self) -> Result<Logger>
pub fn build(self) -> Result<Logger>
use the configured settings to build and initialize a new global Logger
This will build a functional Logger. You don’t need to use the Logger struct, it’s better to use the macros:
error!warn!info!debug!trace!
instead of the methods of the Logger struct. You can however use the Logger struct in cases where usage of a macro is bad or you are somehow working with multiple loggers.
§Examples
Logger::builder()
.uptime(true)
.build();
info!("hello world");
§Errors
This function will return an error if a global Logger was aready initialized. This module uses the tracing crate for logging, so if a tracing logger is initialized elsewhere, this method will error.
sourcepub const fn log_to_file(self, log_to_file: bool) -> Self
pub const fn log_to_file(self, log_to_file: bool) -> Self
enable or disable logging to and creating of logfiles
If you want to log to a file, don’t forget to set Self::log_dir!
Default: false
sourcepub fn log_dir(self, log_dir: PathBuf) -> Self
pub fn log_dir(self, log_dir: PathBuf) -> Self
set a directory where logfiles would be created in
Enable or disable creation and logging to logfiles with log_to_file.
Default: DEFAULT_LOG_DIR (/dev/null)
sourcepub const fn ansi(self, ansi: bool) -> Self
pub const fn ansi(self, ansi: bool) -> Self
enable or disable ANSI control sequences
Disabling ANSI control sequences might improve compatibility and readability when the logs are displayed by a program that does not interpret them.
Keeping ANSI control sequences enabled has the disadvantage of added colors for the logs.
Default: true
sourcepub const fn display_filename(self, display_filename: bool) -> Self
pub const fn display_filename(self, display_filename: bool) -> Self
when making a log, display the source file in which a log was crated in
Default: false
sourcepub const fn display_time(self, show_time: bool) -> Self
pub const fn display_time(self, show_time: bool) -> Self
when making a log, display the time of the message
Default: true
sourcepub const fn display_level(self, display_level: bool) -> Self
pub const fn display_level(self, display_level: bool) -> Self
when making a log, display the log level of the message
Default: true
sourcepub const fn display_target(self, display_target: bool) -> Self
pub const fn display_target(self, display_target: bool) -> Self
show target context
Default: false
sourcepub const fn display_thread_ids(self, display_thread_ids: bool) -> Self
pub const fn display_thread_ids(self, display_thread_ids: bool) -> Self
show the id of the thread that created this message
Default: false
sourcepub const fn display_thread_names(self, display_thread_names: bool) -> Self
pub const fn display_thread_names(self, display_thread_names: bool) -> Self
show the name of the thread that created this message
Default: false
sourcepub const fn display_line_number(self, display_line_number: bool) -> Self
pub const fn display_line_number(self, display_line_number: bool) -> Self
show which line in the source file produces a log
Default: false
sourcepub const fn pretty(self, pretty: bool) -> Self
pub const fn pretty(self, pretty: bool) -> Self
splits a log over multiple lines, looks like a python traceback
Default: false
sourcepub const fn uptime(self, uptime: bool) -> Self
pub const fn uptime(self, uptime: bool) -> Self
show timestamps as uptime (duration since the logger was initialized)
Default: false
sourcepub const fn set_level(self, max_level: Level) -> Self
pub const fn set_level(self, max_level: Level) -> Self
set the lowest loglevel to be displayed
Default: Level::INFO
Trait Implementations§
source§impl Debug for LoggerBuilder
impl Debug for LoggerBuilder
source§impl Default for LoggerBuilder
impl Default for LoggerBuilder
source§impl Hash for LoggerBuilder
impl Hash for LoggerBuilder
source§impl Ord for LoggerBuilder
impl Ord for LoggerBuilder
source§fn cmp(&self, other: &LoggerBuilder) -> Ordering
fn cmp(&self, other: &LoggerBuilder) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for LoggerBuilder
impl PartialEq for LoggerBuilder
source§fn eq(&self, other: &LoggerBuilder) -> bool
fn eq(&self, other: &LoggerBuilder) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for LoggerBuilder
impl PartialOrd for LoggerBuilder
source§fn partial_cmp(&self, other: &LoggerBuilder) -> Option<Ordering>
fn partial_cmp(&self, other: &LoggerBuilder) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more