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 fn log_to_file(self, log_to_file: bool) -> Self
pub fn log_to_file(self, log_to_file: bool) -> Self
enable or disable logging to and creating of logfiles
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.
The default logdir is DEFAULT_LOG_DIR.
sourcepub fn ansi(self, ansi: bool) -> Self
pub 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.
sourcepub fn display_filename(self, display_filename: bool) -> Self
pub fn display_filename(self, display_filename: bool) -> Self
when making a log, display the source file in which a log was crated in
sourcepub fn display_level(self, display_level: bool) -> Self
pub fn display_level(self, display_level: bool) -> Self
when making a log, display the log level of the message
sourcepub fn display_target(self, display_target: bool) -> Self
pub fn display_target(self, display_target: bool) -> Self
show target context
sourcepub fn display_thread_ids(self, display_thread_ids: bool) -> Self
pub fn display_thread_ids(self, display_thread_ids: bool) -> Self
show the id of the thread that created this message
sourcepub fn display_thread_names(self, display_thread_names: bool) -> Self
pub fn display_thread_names(self, display_thread_names: bool) -> Self
show the name of the thread that created this message
sourcepub fn display_line_number(self, display_line_number: bool) -> Self
pub fn display_line_number(self, display_line_number: bool) -> Self
show which line in the source file produces a log
sourcepub fn pretty(self, pretty: bool) -> Self
pub fn pretty(self, pretty: bool) -> Self
splits a log over multiple lines, looks like a python traceback
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