From 1b3b2be9450b956167aaf542b02028f13440831d Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 30 Oct 2004 08:47:03 +0000 Subject: [PATCH] added smarter exception logging darcs-hash:20041030084703-5007d-abe94794aaf67d286e1e1cfb919b917b4fe48bd7.gz --- src/org/ibex/util/Log.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/org/ibex/util/Log.java b/src/org/ibex/util/Log.java index 7b3a0d7..5c67f68 100644 --- a/src/org/ibex/util/Log.java +++ b/src/org/ibex/util/Log.java @@ -19,6 +19,7 @@ public class Log { public static boolean verbose = System.getProperty("ibex.log.verbose", "false").equals("true"); public static boolean logDates = System.getProperty("ibex.log.dates", "false").equals("true"); public static boolean notes = System.getProperty("ibex.log.notes.on", "true").equals("true"); + public static boolean stackTraces = System.getProperty("ibex.log.stackTraces", "true").equals("true"); public static int maximumNoteLength = Integer.parseInt(System.getProperty("ibex.log.notes.maximumLength", (1024 * 32)+"")); public static boolean rpc = false; public static Date lastDate = null; @@ -169,16 +170,24 @@ public class Log { } byte[] b = baos.toByteArray(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b))); - String s = null; try { - String m = ""; - while((s = br.readLine()) != null) m += s + "\n"; - if (m.length() > 0) log(o, m.substring(0, m.length() - 1), level); + if (stackTraces) { + String s = null; + String m = ""; + while((s = br.readLine()) != null) m += s + "\n"; + if (m.length() > 0) log(o, m.substring(0, m.length() - 1), level); + } else { + message = br.readLine(); + String s = br.readLine(); + if (s.indexOf('(') != -1) message = message + " " + s.substring(s.indexOf('(')); + log(o, message, level); + } + lastClassName = ""; } catch (IOException e) { // FEATURE: use org.ibex.io.Stream's here - logstream.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream; this should not happen")); + logstream.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream;" + + " this should not happen")); } - lastClassName = ""; return; } -- 1.7.10.4