From f28bfadf8d97bff7880dc3f7d28de3cb3bc18548 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Apr 2016 17:35:59 +0200 Subject: [PATCH] logger: Print file and line on debug printing --- libimagrt/src/logger.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libimagrt/src/logger.rs b/libimagrt/src/logger.rs index 181f3372..302d790a 100644 --- a/libimagrt/src/logger.rs +++ b/libimagrt/src/logger.rs @@ -26,7 +26,13 @@ impl Log for ImagLogger { fn log(&self, record: &LogRecord) { if self.enabled(record.metadata()) { // TODO: This is just simple logging. Maybe we can enhance this lateron - writeln!(stderr(), "[imag][{: <5}]: {}", record.level(), record.args()).ok(); + if record.metadata().level() == LogLevel::Debug { + let loc = record.location(); + writeln!(stderr(), "[imag][{: <5}][{}][{: >5}]: {}", + record.level(), loc.file(), loc.line(), record.args()).ok(); + } else { + writeln!(stderr(), "[imag][{: <5}]: {}", record.level(), record.args()).ok(); + } } } }