better logging handling
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
pub fn setup_logger() -> Result<(), fern::InitError> {
|
||||
fern::Dispatch::new()
|
||||
.format(|out, message, record| {
|
||||
.format(move |out, message, record| {
|
||||
out.finish(format_args!(
|
||||
"{}[{}][{}] {}",
|
||||
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
|
||||
std::thread::current().name().expect("unnamed_thread"),
|
||||
"[{}][{}][{}] {}",
|
||||
humantime::format_rfc3339_millis(std::time::SystemTime::now()),
|
||||
std::thread::current().name().unwrap_or("unnamed_thread"),
|
||||
record.level(),
|
||||
message
|
||||
))
|
||||
})
|
||||
.level(log::LevelFilter::Debug)
|
||||
.chain(std::io::stdout())
|
||||
.chain(fern::log_file("output.log")?)
|
||||
.chain(fern::log_file(format!(
|
||||
"output_{}.log",
|
||||
humantime::format_rfc3339_seconds(std::time::SystemTime::now())
|
||||
))?)
|
||||
.apply()?;
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user