feat: add fern

This commit is contained in:
2020-12-26 09:45:28 +08:00
parent 88c4ba5c94
commit 895385a2b5
3 changed files with 154 additions and 0 deletions

25
__log/fern/src/main.rs Normal file
View File

@@ -0,0 +1,25 @@
#[macro_use] extern crate log;
use log::warn;
fn main() {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{}[{}][{}] {}",
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
record.target(),
record.level(),
message
))
})
.level(log::LevelFilter::Debug)
// .level_for(module, level)
.chain(std::io::stdout())
.apply().unwrap();
debug!("Hello, world!");
info!("Hello, world!");
warn!("Hello, world!");
error!("Hello, world!");
}