JUL: use root logger to capture events
[lttng-ust.git] / liblttng-ust-jul / org / lttng / ust / jul / LTTngLogHandler.java
index 8c795127bfc52958804dff8101404404003bccc9..4c617fb91918f0afe192b66836782bb2178b6d68 100644 (file)
@@ -29,40 +29,16 @@ import java.util.Map;
 
 import org.lttng.ust.jul.LTTngUst;
 
-class LTTngLogger {
-       /*
-        * The log handler is attached to the logger when the reference count is
-        * nonzero. Each event referring to a logger holds a reference to that
-        * logger. If down to 0, this object is removed from the handler.
-        */
-       public int refcount;
-       public String name;
-       Logger logger;
-
-       public LTTngLogger(String name, Logger logger) {
-               this.name = name;
-               this.refcount = 0;
-               this.logger = logger;
-       }
-
-       public void attach(LTTngLogHandler handler) {
-               this.logger.addHandler(handler);
-       }
-
-       public void detach(LTTngLogHandler handler) {
-               this.logger.removeHandler(handler);
-       }
-}
-
 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. */
-       private Map<String, LTTngLogger> loggerMap =
-               Collections.synchronizedMap(new HashMap<String, LTTngLogger>());
+       public Map<String, LTTngEvent> enabledEvents =
+               Collections.synchronizedMap(new HashMap<String, LTTngEvent>());
 
        /* Constructor */
        public LTTngLogHandler(LogManager logManager) {
@@ -74,69 +50,11 @@ public class LTTngLogHandler extends Handler {
                LTTngUst.init();
        }
 
-       /*
-        * Return true if the logger is enabled and attached. Else, if not found,
-        * return false.
-        */
-       public boolean exists(String name) {
-               if (loggerMap.get(name) != null) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /*
-        * Attach an event to this handler. If no logger object exists, one is
-        * created else the refcount is incremented.
-        */
-       public void attachEvent(LTTngEvent event) {
-               Logger logger;
-               LTTngLogger lttngLogger;
-
-               /* Does the logger actually exist. */
-               logger = this.logManager.getLogger(event.name);
-               if (logger == null) {
-                       /* Stop attach right now. */
-                       return;
-               }
-
-               lttngLogger = loggerMap.get(event.name);
-               if (lttngLogger == null) {
-                       lttngLogger = new LTTngLogger(event.name, logger);
-
-                       /* Attach the handler to the logger and add is to the map. */
-                       lttngLogger.attach(this);
-                       lttngLogger.refcount = 1;
-                       loggerMap.put(lttngLogger.name, lttngLogger);
-               } else {
-                       lttngLogger.refcount += 1;
-               }
-       }
-
-       /*
-        * Dettach an event from this handler. If the refcount goes down to 0, the
-        * logger object is removed thus not attached anymore.
-        */
-       public void detachEvent(LTTngEvent event) {
-               LTTngLogger logger;
-
-               logger = loggerMap.get(event.name);
-               if (logger != null) {
-                       logger.refcount -= 1;
-                       if (logger.refcount == 0) {
-                               /* Dettach from handler since no more event is associated. */
-                               logger.detach(this);
-                               loggerMap.remove(logger);
-                       }
-               }
-       }
-
        /*
         * Cleanup this handler state meaning put it back to a vanilla state.
         */
        public void clear() {
-               this.loggerMap.clear();
+               this.enabledEvents.clear();
        }
 
        @Override
@@ -147,14 +65,6 @@ public class LTTngLogHandler extends Handler {
 
        @Override
        public void publish(LogRecord record) {
-               LTTngLogger logger;
-
-               logger = loggerMap.get(record.getLoggerName());
-               if (logger == null) {
-                       /* Ignore and don't fire TP. */
-                       return;
-               }
-
                /*
                 * Specific tracepoing designed for JUL events. The source class of the
                 * caller is used for the event name, the raw message is taken, the
This page took 0.025319 seconds and 4 git commands to generate.