From f005c8254b3f992fb5fd982a51c6c2bbbd0c050e Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Mon, 20 May 2024 16:06:41 +0800 Subject: [PATCH] chore: logging: print time ticks in metadata --- kernel/src/logging.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/src/logging.rs b/kernel/src/logging.rs index 1fc9ccc..43fd0ef 100644 --- a/kernel/src/logging.rs +++ b/kernel/src/logging.rs @@ -1,6 +1,7 @@ -use crate::entry::HART_ID; use crate::plat::console::CONSOLE; +use crate::{entry::HART_ID, plat::timer::CURRENT_TICK}; use core::fmt::Write; +use core::sync::atomic::Ordering; use log::{LevelFilter, Log, Metadata, Record}; struct SimpleLogger; @@ -28,9 +29,10 @@ impl Log for SimpleLogger { CONSOLE .lock() .write_fmt(format_args!( - "{color_prefix}[{}][HART{}] {}{color_reset}\n", + "{color_prefix}[{}][HART{}][{}] {}{color_reset}\n", record.level(), HART_ID.get(), + CURRENT_TICK.load(Ordering::Acquire), record.args(), )) .unwrap();