1
0

Improve log output

This commit is contained in:
Jeff 2024-12-01 21:31:43 -05:00
parent 3146e70bf1
commit 299610e16f

View File

@ -80,7 +80,7 @@ impl GlobalArguments {
let mut logger = env_logger::builder(); let mut logger = env_logger::builder();
logger.format(move |buf, record| { logger.format(move |buf, record| {
let elapsed = start_time.elapsed().as_nanos(); let elapsed = format!("T+{:.04}", start_time.elapsed().as_secs_f32()).dimmed();
let level_display = match record.level() { let level_display = match record.level() {
Level::Info => "INFO".bold().white(), Level::Info => "INFO".bold().white(),
Level::Debug => "DEBUG".bold().blue(), Level::Debug => "DEBUG".bold().blue(),
@ -88,15 +88,7 @@ impl GlobalArguments {
Level::Error => "ERROR".bold().red(), Level::Error => "ERROR".bold().red(),
Level::Trace => "TRACE".bold().purple(), Level::Trace => "TRACE".bold().purple(),
}; };
let module = record let display = format!("[{elapsed}] {level_display:5} {args}", args = record.args());
.module_path()
.map(|path| path.split("::").last().unwrap_or(path))
.unwrap_or("unknown")
.dimmed();
let display = format!(
"{elapsed} {level_display:5} {module:^6} {args}",
args = record.args()
);
writeln!(buf, "{display}") writeln!(buf, "{display}")
}); });