JUL: use root logger to capture events
[lttng-ust.git] / liblttng-ust-jul / org / lttng / ust / jul / LTTngLogHandler.java
index dfc15b3df65115fbf91879ceac5bf5f3f7737616..4c617fb91918f0afe192b66836782bb2178b6d68 100644 (file)
@@ -21,12 +21,26 @@ import java.lang.String;
 import java.util.logging.Handler;
 import java.util.logging.LogRecord;
 import java.util.logging.LogManager;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.lttng.ust.jul.LTTngUst;
 
 public class LTTngLogHandler extends Handler {
+       /* Am I a root Log Handler. */
+       public int is_root = 0;
+       public int refcount = 0;
+
        public LogManager logManager;
 
+       /* Logger object attached to this handler that can trigger a tracepoint. */
+       public Map<String, LTTngEvent> enabledEvents =
+               Collections.synchronizedMap(new HashMap<String, LTTngEvent>());
+
+       /* Constructor */
        public LTTngLogHandler(LogManager logManager) {
                super();
 
@@ -36,6 +50,13 @@ public class LTTngLogHandler extends Handler {
                LTTngUst.init();
        }
 
+       /*
+        * Cleanup this handler state meaning put it back to a vanilla state.
+        */
+       public void clear() {
+               this.enabledEvents.clear();
+       }
+
        @Override
        public void close() throws SecurityException {}
 
@@ -49,9 +70,16 @@ public class LTTngLogHandler extends Handler {
                 * caller is used for the event name, the raw message is taken, the
                 * loglevel of the record and the thread ID.
                 */
-               LTTngUst.tracepoint(record.getMessage(), record.getLoggerName(),
-                               record.getSourceClassName(), record.getSourceMethodName(),
-                               record.getMillis(), record.getLevel().intValue(),
-                               record.getThreadID());
+               if (this.is_root == 1) {
+                       LTTngUst.tracepointS(record.getMessage(),
+                                       record.getLoggerName(), record.getSourceClassName(),
+                                       record.getSourceMethodName(), record.getMillis(),
+                                       record.getLevel().intValue(), record.getThreadID());
+               } else {
+                       LTTngUst.tracepointU(record.getMessage(),
+                                       record.getLoggerName(), record.getSourceClassName(),
+                                       record.getSourceMethodName(), record.getMillis(),
+                                       record.getLevel().intValue(), record.getThreadID());
+               }
        }
 }
This page took 0.044495 seconds and 4 git commands to generate.