main: Add thread name to log output

If there is no thread then the name is reported as "anonymous".

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-12-18 14:47:39 +00:00
parent e8c72b1b01
commit 8a27735826

View File

@ -73,8 +73,9 @@ impl log::Log for Logger {
if record.file().is_some() && record.line().is_some() { if record.file().is_some() && record.line().is_some() {
writeln!( writeln!(
*(*(self.output.lock().unwrap())), *(*(self.output.lock().unwrap())),
"cloud-hypervisor: {:?}: {}:{}:{} -- {}", "cloud-hypervisor: {:?}: <{}> {}:{}:{} -- {}",
duration, duration,
std::thread::current().name().unwrap_or("anonymous"),
record.level(), record.level(),
record.file().unwrap(), record.file().unwrap(),
record.line().unwrap(), record.line().unwrap(),
@ -83,8 +84,9 @@ impl log::Log for Logger {
} else { } else {
writeln!( writeln!(
*(*(self.output.lock().unwrap())), *(*(self.output.lock().unwrap())),
"cloud-hypervisor: {:?}: {}:{} -- {}", "cloud-hypervisor: {:?}: <{}> {}:{} -- {}",
duration, duration,
std::thread::current().name().unwrap_or("anonymous"),
record.level(), record.level(),
record.target(), record.target(),
record.args() record.args()