Fix: Wrong CLASSPATH when building liblttng-ust-java oot
[lttng-ust.git] / liblttng-ust-jul / org / lttng / ust / jul / LTTngLogHandler.java
CommitLineData
43e5396b
DG
1/*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18package org.lttng.ust.jul;
19
20import java.lang.String;
21import java.util.logging.Handler;
22import java.util.logging.LogRecord;
23import java.util.logging.LogManager;
a15440fd 24import java.util.logging.Level;
96caa5ed
DG
25import java.util.logging.Logger;
26import java.util.Collections;
a15440fd 27import java.util.HashMap;
96caa5ed 28import java.util.Map;
43e5396b
DG
29
30import org.lttng.ust.jul.LTTngUst;
31
96caa5ed 32public class LTTngLogHandler extends Handler {
9aabed2d
DG
33 /* Am I a root Log Handler. */
34 public int is_root = 0;
9663e532 35 public int refcount = 0;
9aabed2d 36
96caa5ed 37 /* Logger object attached to this handler that can trigger a tracepoint. */
9663e532
DG
38 public Map<String, LTTngEvent> enabledEvents =
39 Collections.synchronizedMap(new HashMap<String, LTTngEvent>());
a15440fd 40
96caa5ed 41 /* Constructor */
501f6777 42 public LTTngLogHandler() {
43e5396b 43 super();
43e5396b
DG
44 /* Initialize LTTng UST tracer. */
45 LTTngUst.init();
46 }
47
87d64abb
DG
48 /*
49 * Cleanup this handler state meaning put it back to a vanilla state.
50 */
51 public void clear() {
9663e532 52 this.enabledEvents.clear();
87d64abb
DG
53 }
54
43e5396b
DG
55 @Override
56 public void close() throws SecurityException {}
57
58 @Override
59 public void flush() {}
60
61 @Override
62 public void publish(LogRecord record) {
63 /*
64 * Specific tracepoing designed for JUL events. The source class of the
65 * caller is used for the event name, the raw message is taken, the
66 * loglevel of the record and the thread ID.
67 */
9aabed2d
DG
68 if (this.is_root == 1) {
69 LTTngUst.tracepointS(record.getMessage(),
70 record.getLoggerName(), record.getSourceClassName(),
71 record.getSourceMethodName(), record.getMillis(),
72 record.getLevel().intValue(), record.getThreadID());
73 } else {
74 LTTngUst.tracepointU(record.getMessage(),
75 record.getLoggerName(), record.getSourceClassName(),
76 record.getSourceMethodName(), record.getMillis(),
77 record.getLevel().intValue(), record.getThreadID());
78 }
43e5396b
DG
79 }
80}
This page took 0.026199 seconds and 4 git commands to generate.