pub struct Logger;Expand description
§Logger for pt
A logger is generally a functionality that let’s you write information from your library or
application in a more structured manner than if you just wrote all information to stdout or
stderr with the likes of println! or eprintln!.
It offers writing to multiple targets, such as both the terminal and a log file, and allows users to choose the verbosity of the information that gets printed by selecting a Loglevel.
§Levels
TODO: add levels desc and ascii art
§Usage
You don’t need to use the Logger struct, it’s better to use the macros instead:
error!warn!info!debug!trace!
You can however use the Logger struct in cases where usage of a macro is bad or
you are somehow working with multiple loggers. The macros offer additional functionalities,
suck as full format! support and context, see tracing, which we use as backend.
§Examples
Logger::builder()
.uptime(true)
.build();
info!("hello world");
Implementations§
source§impl Logger
impl Logger
§Main implementation
sourcepub fn builder() -> LoggerBuilder
pub fn builder() -> LoggerBuilder
Get a new LoggerBuilder
sourcepub fn build(
log_dir: Option<PathBuf>,
max_level: Option<Level>,
uptime: bool
) -> Result<Self>
👎Deprecated since 0.4.1: use Logger::builder() instead
pub fn build( log_dir: Option<PathBuf>, max_level: Option<Level>, uptime: bool ) -> Result<Self>
§initializes the logger
Will enable the logger to be used.
Assumes some defaults, use init_customized for more control
sourcepub fn build_mini(max_level: Option<Level>) -> Result<Self>
👎Deprecated since 0.4.1: use Logger::builder() instead
pub fn build_mini(max_level: Option<Level>) -> Result<Self>
§initializes the logger
Will enable the logger to be used. This is a version that shows less information, useful in cases with only one sender to the logging framework.
Assumes some defaults, use init_customized for more control
sourcepub fn build_customized(
log_to_file: bool,
log_dir: PathBuf,
ansi: bool,
display_filename: bool,
display_level: bool,
display_target: bool,
max_level: Level,
display_thread_ids: bool,
display_thread_names: bool,
display_line_number: bool,
pretty: bool,
show_time: bool,
uptime: bool
) -> Result<Self>
👎Deprecated since 0.4.1: use Logger::builder() instead
pub fn build_customized( log_to_file: bool, log_dir: PathBuf, ansi: bool, display_filename: bool, display_level: bool, display_target: bool, max_level: Level, display_thread_ids: bool, display_thread_names: bool, display_line_number: bool, pretty: bool, show_time: bool, uptime: bool ) -> Result<Self>
§initializes the logger
Will enable the logger to be used.