added Log.setThreadAnnotation()
[org.ibex.core.git] / src / org / ibex / util / Log.java
index 5d09216..beb7f3e 100644 (file)
@@ -33,6 +33,9 @@ public class Log {
         logstream = new PrintStream(new Socket(InetAddress.getByName(host), port).getOutputStream());
     }
 
+    private static Hashtable threadAnnotations = new Hashtable();
+    public static void setThreadAnnotation(String s) { threadAnnotations.put(Thread.currentThread(), s); }
+
     /** true iff nothing has yet been logged */
     public static boolean firstMessage = true;
 
@@ -119,6 +122,8 @@ public class Log {
             lastDate = d;
         }
 
+        String annot = (String)threadAnnotations.get(Thread.currentThread());
+        if (annot != null) classname += annot;
 
         if (message instanceof Throwable) {
             if (level < ERROR) level = WARN;
@@ -134,10 +139,12 @@ public class Log {
             } catch (IOException e) {
                 logstream.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
             }
+            lastClassName = "";
             return;
         }
 
         String str = message.toString();
+        if (str.indexOf('\n') != -1) lastClassName = "";
         while(str.indexOf('\t') != -1)
             str = str.substring(0, str.indexOf('\t')) + "    " + str.substring(str.indexOf('\t') + 1);