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();
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 {}
* 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());
+ }
}
}