Crate pretty_flexible_env_logger
source ·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
Initializes default global logger.
Initializes default global logger with timed entries.
Initializes the timed global logger with a custom configuration.
Initializes the global logger with a custom configuration.
Tries to initialize default global logger.
Tries to initialize the global logger with custom filtering directives.
Tries to initialize default global logger with timed entries.
Tries to initialize the timed global logger with custom filtering directives.
Tries to initialize the timed global logger with a custom configuration.
Tries to initialize the global logger with a custom configuration.