From 96c3f6294046c5d003cb463d195db5cb6331f74f Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 12 May 2019 18:20:43 +0200 Subject: [PATCH] add time in default trace handler --- src/be/nikiroo/utils/TraceHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/be/nikiroo/utils/TraceHandler.java b/src/be/nikiroo/utils/TraceHandler.java index 12ae849b..e1dc50fb 100644 --- a/src/be/nikiroo/utils/TraceHandler.java +++ b/src/be/nikiroo/utils/TraceHandler.java @@ -91,6 +91,8 @@ public class TraceHandler { public void error(Exception e) { if (showErrors) { if (showErrorDetails) { + long now = System.currentTimeMillis(); + System.err.print(StringUtils.fromTime(now) + ": "); e.printStackTrace(); } else { error(e.getMessage()); @@ -106,7 +108,8 @@ public class TraceHandler { */ public void error(String message) { if (showErrors) { - System.err.println(message); + long now = System.currentTimeMillis(); + System.err.println(StringUtils.fromTime(now) + ": " + message); } } @@ -139,7 +142,10 @@ public class TraceHandler { */ public void trace(String message, int level) { if (traceLevel > 0 && level <= traceLevel) { + long now = System.currentTimeMillis(); + System.err.print(StringUtils.fromTime(now) + ": "); if (maxPrintSize > 0 && message.length() > maxPrintSize) { + System.err .println(message.substring(0, maxPrintSize) + "[...]"); } else { -- 2.27.0