logs
A simple terminal logger
Usage
Add this in your Cargo.toml
:
[dependencies]
logs = "*"
Example
use logs::{debug, error, info, trace, warn};
fn main() {
debug!("This is a debug log");
trace!("This is a trace log");
info!("This is a info log");
warn!("This is a warn log");
error!("This is a error log");
}
Config
use logs::{Config, debug, error};
fn main() {
let mut config = Config::disable_all();
config.debug(false);
config.error(true);
#[cfg(debug_assertions)]
config.trace(true);
config.date_format("%c").unwrap();
config.init();
debug!("This is a debug log");
error!("This is a error log");
}
env
This can be configured by reading the LOG
environment variable, which disables all output by default
export LOG='all,!debug,info,!error'
use logs::Config;
fn main() {
Config::from_env().unwrap().init();
}