Add filename and line no to log entries

This is done for all logging calls, also those which call error! which
is normally directly shown to the user.
This commit is contained in:
Floris Bruynooghe
2019-12-15 23:58:10 +01:00
committed by holger krekel
parent 1ee15942cc
commit 19e716b522
2 changed files with 7 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ extern crate strum_macros;
extern crate debug_stub_derive;
#[macro_use]
mod log;
pub mod log;
#[macro_use]
pub mod error;

View File

@@ -7,7 +7,8 @@ macro_rules! info {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
emit_event!($ctx, $crate::Event::Info(formatted));
let full = format!("{}:{}: {}", file!(), line!(), &formatted);
emit_event!($ctx, $crate::Event::Info(full));
}};
}
@@ -18,7 +19,8 @@ macro_rules! warn {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
emit_event!($ctx, $crate::Event::Warning(formatted));
let full = format!("{}:{}: {}", file!(), line!(), &formatted);
emit_event!($ctx, $crate::Event::Warning(full));
}};
}
@@ -29,7 +31,8 @@ macro_rules! error {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
emit_event!($ctx, $crate::Event::Error(formatted));
let full = format!("{}:{}: {}", file!(), line!(), &formatted);
emit_event!($ctx, $crate::Event::Error(full));
}};
}