Add the thread id and name to info and warn log output

This commit is contained in:
Floris Bruynooghe
2019-12-16 01:30:01 +01:00
committed by holger krekel
parent e3031462c1
commit d7f345eef8

View File

@@ -7,7 +7,13 @@ macro_rules! info {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
let full = format!("{}:{}: {}", file!(), line!(), &formatted);
let thread = ::std::thread::current();
let full = format!("{thid:?}/{thname} {file}:{line}: {msg}",
thid = thread.id(),
thname = thread.name().unwrap_or("unnamed"),
file = file!(),
line = line!(),
msg = &formatted);
emit_event!($ctx, $crate::Event::Info(full));
}};
}
@@ -19,7 +25,13 @@ macro_rules! warn {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
let full = format!("{}:{}: {}", file!(), line!(), &formatted);
let thread = ::std::thread::current();
let full = format!("{thid:?}/{thname} {file}:{line}: {msg}",
thid = thread.id(),
thname = thread.name().unwrap_or("unnamed"),
file = file!(),
line = line!(),
msg = &formatted);
emit_event!($ctx, $crate::Event::Warning(full));
}};
}