diff options
Diffstat (limited to 'src/logging.rs')
-rw-r--r-- | src/logging.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/logging.rs b/src/logging.rs index 1767724c..893a39a2 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -125,13 +125,26 @@ impl log::Log for Logger { } fn log(&self, record: &log::Record<'_>) { - if self.enabled(record.metadata()) && record.target().starts_with("alacritty") { - let msg = format!( - "[{}] [{}] {}\n", - time::now().strftime("%F %R").unwrap(), - record.level(), - record.args() - ); + if self.enabled(record.metadata()) && + record.target().starts_with("alacritty") + { + let now = time::strftime("%F %R", &time::now()).unwrap(); + + let msg = if record.level() >= Level::Trace { + format!("[{}] [{}] [{}:{}] {}\n", + now, + record.level(), + record.file().unwrap_or("?"), + record.line() + .map(|l| l.to_string()) + .unwrap_or("?".to_string()), + record.args()) + } else { + format!("[{}] [{}] {}\n", + now, + record.level(), + record.args()) + }; if let Ok(ref mut logfile) = self.logfile.lock() { let _ = logfile.write_all(msg.as_ref()); |