From 8a2773582621ef2370d0baf539b682a9737ae043 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 18 Dec 2020 14:47:39 +0000 Subject: [PATCH] main: Add thread name to log output If there is no thread then the name is reported as "anonymous". Signed-off-by: Rob Bradford --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0859d4184..e4a832aab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,8 +73,9 @@ impl log::Log for Logger { if record.file().is_some() && record.line().is_some() { writeln!( *(*(self.output.lock().unwrap())), - "cloud-hypervisor: {:?}: {}:{}:{} -- {}", + "cloud-hypervisor: {:?}: <{}> {}:{}:{} -- {}", duration, + std::thread::current().name().unwrap_or("anonymous"), record.level(), record.file().unwrap(), record.line().unwrap(), @@ -83,8 +84,9 @@ impl log::Log for Logger { } else { writeln!( *(*(self.output.lock().unwrap())), - "cloud-hypervisor: {:?}: {}:{} -- {}", + "cloud-hypervisor: {:?}: <{}> {}:{} -- {}", duration, + std::thread::current().name().unwrap_or("anonymous"), record.level(), record.target(), record.args()