From ad4e73399ff98b6f34bc68a40f2a4b19475cc833 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Apr 2016 16:36:13 +0200 Subject: [PATCH 1/2] Make trace() output a bit nicer --- libimagutil/src/trace.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libimagutil/src/trace.rs b/libimagutil/src/trace.rs index f075f037..9f25cfda 100644 --- a/libimagutil/src/trace.rs +++ b/libimagutil/src/trace.rs @@ -55,7 +55,7 @@ fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> { } else { write!(stderr(), "\n").ok(); } - write!(stderr(), "Error {:>4} : {}", idx, e.description()).ok(); + write!(stderr(), "ERROR[{:>4}]: {}", idx, e.description()).ok(); e.cause() } @@ -65,7 +65,7 @@ fn count_error_causes(e: &Error) -> u64 { } fn print_trace_dbg(idx: u64, e: &Error) { - debug!("Error {:>4} : {}", idx, e.description()); + debug!("ERROR[{:>4}]: {}", idx, e.description()); if e.cause().is_some() { debug!(" -- caused by:"); print_trace_dbg(idx + 1, e.cause().unwrap()); From f6e59c355e1388c3b3f1e9e9bf43f6e40fb6270b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Apr 2016 15:10:22 +0200 Subject: [PATCH 2/2] Remove "caused by" marker As we are in debug mode anyways, a developer using this should know by the trace number that the next line is the cause. As we use the debug!() macro here, this would be printed on a new line, which is rather distracting instead of helpful. Therefor this patch removes this line. --- libimagutil/src/trace.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libimagutil/src/trace.rs b/libimagutil/src/trace.rs index 9f25cfda..5b22c84c 100644 --- a/libimagutil/src/trace.rs +++ b/libimagutil/src/trace.rs @@ -67,7 +67,6 @@ fn count_error_causes(e: &Error) -> u64 { fn print_trace_dbg(idx: u64, e: &Error) { debug!("ERROR[{:>4}]: {}", idx, e.description()); if e.cause().is_some() { - debug!(" -- caused by:"); print_trace_dbg(idx + 1, e.cause().unwrap()); } }