sat-rs/satrs-example/src/logger.rs
Robin Mueller b27842c2bb
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
all clippy fixes
2024-01-30 23:48:46 +01:00

18 lines
567 B
Rust

pub fn setup_logger() -> Result<(), fern::InitError> {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{}[{}][{}] {}",
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
std::thread::current().name().expect("unnamed_thread"),
record.level(),
message
))
})
.level(log::LevelFilter::Debug)
.chain(std::io::stdout())
.chain(fern::log_file("output.log")?)
.apply()?;
Ok(())
}