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() {
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()