added smarter exception logging
authoradam <adam@megacz.com>
Sat, 30 Oct 2004 08:47:03 +0000 (08:47 +0000)
committeradam <adam@megacz.com>
Sat, 30 Oct 2004 08:47:03 +0000 (08:47 +0000)
darcs-hash:20041030084703-5007d-abe94794aaf67d286e1e1cfb919b917b4fe48bd7.gz

src/org/ibex/util/Log.java

index 7b3a0d7..5c67f68 100644 (file)
@@ -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;
         }