Refactor liblttng-ust-jul in liblttng-ust-agent
[lttng-ust.git] / liblttng-ust-jul / org / lttng / ust / jul / LTTngLogHandler.java
index dfc15b3df65115fbf91879ceac5bf5f3f7737616..008b105ba916a67b3f109e34ecb6afe227f2c370 100644 (file)
@@ -21,21 +21,37 @@ 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 {
-       public LogManager logManager;
+       /* Am I a root Log Handler. */
+       public int is_root = 0;
+       public int refcount = 0;
 
-       public LTTngLogHandler(LogManager logManager) {
-               super();
-
-               this.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() {
+               super();
                /* Initialize LTTng UST tracer. */
                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 +65,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.02478 seconds and 5 git commands to generate.