Function init

Source
pub fn init(level: LogLevel)
Expand description

Initializes the global logger with the specified minimum log level.

This function creates a logger with default configuration except for the specified log level. It is a convenience wrapper around init_with_config.

§Arguments

  • level - The minimum log level to use

§Panics

Panics if a logger is already initialized

Examples found in repository?
examples/clap.rs (line 15)
12fn main() {
13    let args = Args::parse();
14
15    traccia::init(args.level);
16
17    debug!("This will not be logged if no argument is specified.");
18    info!("This will be logged if no argument is specified.");
19
20    fatal!("Maybe pass -l fatal for only fatal messages to be logged?");
21}
More examples
Hide additional examples
examples/basic.rs (line 4)
3fn main() {
4    traccia::init(LogLevel::Debug);
5
6    // This will not be logged if the log level is set to debug
7    trace!("This is a trace message");
8
9    debug!("This is a debug message");
10    info!("This is an info message");
11    warn!("This is a warn message");
12    error!("This is an error message");
13    fatal!("This is a fatal message");
14}