cleanup: Coding style fixes to the Java agent
[lttng-ust.git] / liblttng-ust-java-agent / java / org / lttng / ust / agent / jul / LTTngLogHandler.java
CommitLineData
501f6777
CB
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.agent.jul;
19
20import java.lang.String;
21
22import java.util.logging.Handler;
23import java.util.logging.LogRecord;
24
25class LTTngLogHandler extends Handler {
08284556
AM
26
27 private final Boolean isRoot;
501f6777
CB
28
29 public LTTngLogHandler(Boolean isRoot) {
30 super();
08284556 31 this.isRoot = isRoot;
501f6777
CB
32 /* Initialize LTTng UST tracer. */
33 try {
34 System.loadLibrary("lttng-ust-jul-jni"); //$NON-NLS-1$
35 } catch (SecurityException e) {
36 e.printStackTrace();
37 } catch (UnsatisfiedLinkError e) {
38 e.printStackTrace();
39 } catch (NullPointerException e) {
40 /* Should never happen */
41 e.printStackTrace();
42 }
43 }
44
45 public Boolean isRoot() {
08284556 46 return this.isRoot;
501f6777
CB
47 }
48
49 @Override
50 public void close() throws SecurityException {}
51
52 @Override
53 public void flush() {}
54
55 @Override
56 public void publish(LogRecord record) {
57 /*
08284556 58 * Specific tracepoint designed for JUL events. The source class of the
501f6777
CB
59 * caller is used for the event name, the raw message is taken, the
60 * loglevel of the record and the thread ID.
61 */
08284556 62 if (this.isRoot) {
501f6777
CB
63 tracepointS(record.getMessage(),
64 record.getLoggerName(), record.getSourceClassName(),
65 record.getSourceMethodName(), record.getMillis(),
66 record.getLevel().intValue(), record.getThreadID());
67 } else {
68 tracepointU(record.getMessage(),
69 record.getLoggerName(), record.getSourceClassName(),
70 record.getSourceMethodName(), record.getMillis(),
71 record.getLevel().intValue(), record.getThreadID());
72 }
73 }
74
75 /* Use for a user session daemon. */
08284556
AM
76 private native void tracepointU(String msg,
77 String logger_name,
78 String class_name,
79 String method_name,
80 long millis,
81 int log_level,
82 int thread_id);
501f6777
CB
83
84 /* Use for a root session daemon. */
08284556
AM
85 private native void tracepointS(String msg,
86 String logger_name,
87 String class_name,
88 String method_name,
89 long millis,
90 int log_level,
91 int thread_id);
501f6777 92}
This page took 0.025843 seconds and 4 git commands to generate.