Expand description
A logger configured via run-time value or one taken from an environment variable which writes to standard error with nice colored output for log levels.
§Example
use log::{debug,info,warn,error};
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let default = "RUST_LOG".to_string();
let level = args.get(1).unwrap_or(&default);
if let Err(e) = pretty_flexible_env_logger::try_init_with(level) {
eprintln!("Some custom msg {}", e);
panic!("error!") // or whatever
}
info!("info");
warn!("warn");
error!("error");
debug!("debug");
}§Defaults
The defaults can be setup by calling init() or try_init() at the start of the program.
§Enable logging
This crate uses pretty_env_logger internally, so the same ways of enabling logs through an environment variable are supported.
Functions§
- init
- Initializes default global logger.
- init_
timed - Initializes default global logger with timed entries.
- init_
timed_ with - Initializes the timed global logger with a custom configuration.
- init_
with - Initializes the global logger with a custom configuration.
- try_
init - Tries to initialize default global logger.
- try_
init_ custom_ string - Tries to initialize the global logger with custom filtering directives.
- try_
init_ timed - Tries to initialize default global logger with timed entries.
- try_
init_ timed_ custom_ string - Tries to initialize the timed global logger with custom filtering directives.
- try_
init_ timed_ with - Tries to initialize the timed global logger with a custom configuration.
- try_
init_ with - Tries to initialize the global logger with a custom configuration.