#[cfg(all(feature = "termcolor", feature = "humantime"))]
fn main() {
use env_logger::{fmt, Builder, Env};
use std::io::Write;
fn init_logger() {
let env = Env::default()
.filter("MY_LOG_LEVEL")
.write_style("MY_LOG_STYLE");
Builder::from_env(env)
.format(|buf, record| {
let mut style = buf.style();
style.set_bg(fmt::Color::Yellow).set_bold(true);
let timestamp = buf.timestamp();
writeln!(
buf,
"My formatted log ({}): {}",
timestamp,
style.value(record.args())
)
})
.init();
}
init_logger();
log::info!("a log from `MyLogger`");
}
#[cfg(not(all(feature = "termcolor", feature = "humantime")))]
fn main() {}