use std::fmt;
use log::{debug, info};
fn main() {
fern::Dispatch::new()
.chain(std::io::stdout())
.chain(std::io::stderr())
.chain(fern::log_file("hello.txt").unwrap())
.format(move |out, message, record| {
out.finish(format_args!("[{}] {}", record.level(), message))
})
.apply()
.unwrap();
struct Thing<'a>(&'a str);
impl<'a> fmt::Display for Thing<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
debug!("formatting Thing wrapping ({})", self.0);
f.write_str(self.0)
}
}
info!("I'm logging {}!", Thing("aha"));
}