- /* Wild card to enable ALL logger. */
- if (name.trim().equals("*")) {
- String loggerName;
- Enumeration loggers = handler.logManager.getLoggerNames();
-
- /* Add event to the wildcard set. */
- wildCardSet.add(new LTTngEvent(name.trim(), lttngLogLevel,
- lttngLogLevelType));
-
- /*
- * Create an event for each logger found and attach it to the
- * handler.
- */
- while (loggers.hasMoreElements()) {
- loggerName = loggers.nextElement().toString();
- /* Somehow there is always an empty string at the end. */
- if (loggerName == "") {
- continue;
- }
-
- event = new LTTngEvent(loggerName, lttngLogLevel,
- lttngLogLevelType);
- /* Attach event to Log handler to it can be traced. */
- handler.attachEvent(event);
-
- /*
- * The agent timer call this function with eventMap set to
- * null because it already has a reference to an existing
- * event so is should not try to add a new one here.
- */
- if (eventMap != null) {
- bucket = eventMap.get(loggerName);
- if (bucket == null) {
- bucket = new ArrayList<LTTngEvent>();
- eventMap.put(loggerName, bucket);
- }
- bucket.add(event);
- }
- }
- } else {
- event = new LTTngEvent(name.trim(), lttngLogLevel,
- lttngLogLevelType);
- /* Attach event to Log handler to it can be traced. */
- handler.attachEvent(event);
-
- /*
- * The agent timer call this function with eventMap set to
- * null because it already has a reference to an existing
- * event so is should not try to add a new one here.
- */
- if (eventMap != null) {
- bucket = eventMap.get(name.trim());
- if (bucket == null) {
- bucket = new ArrayList<LTTngEvent>();
- eventMap.put(name.trim(), bucket);
- }
- bucket.add(event);
- }
+ /* Add event to the enabled events hash map. */
+ event = handler.enabledEvents.put(this.name,
+ new LTTngEvent(this.name, 0, 0));
+ if (event != null) {
+ /* The event exists so skip updating the refcount. */
+ this.code = lttng_jul_ret_code.CODE_SUCCESS_CMD;
+ return;
+ }
+
+ /*
+ * Get the root logger and attach to it if it's the first enable
+ * seen by the handler.
+ */
+ Logger rootLogger = handler.logManager.getLogger("");
+
+ handler.refcount++;
+ if (handler.refcount == 1) {
+ /* Add handler only if it's the first enable. */
+ rootLogger.addHandler(handler);