2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
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.
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
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
18 package org
.lttng
.ust
.agent
.jul
;
20 import java
.lang
.String
;
22 import java
.util
.logging
.Formatter
;
23 import java
.util
.logging
.Handler
;
24 import java
.util
.logging
.LogRecord
;
26 class LTTngLogHandler
extends Handler
{
29 * Dummy Formatter object, so we can use its
30 * {@link Formatter#formatMessage(LogRecord)} method.
32 private static final Formatter FORMATTER
= new Formatter() {
34 public String
format(LogRecord record
) {
35 throw new UnsupportedOperationException();
39 private final Boolean isRoot
;
41 public LTTngLogHandler(Boolean isRoot
) {
44 /* Initialize LTTng UST tracer. */
46 System
.loadLibrary("lttng-ust-jul-jni"); //$NON-NLS-1$
47 } catch (SecurityException e
) {
49 } catch (UnsatisfiedLinkError e
) {
51 } catch (NullPointerException e
) {
52 /* Should never happen */
57 public Boolean
isRoot() {
62 public void close() throws SecurityException
{}
65 public void flush() {}
68 public void publish(LogRecord record
) {
69 String formattedMessage
= FORMATTER
.formatMessage(record
);
72 * Specific tracepoint designed for JUL events. The source class of the
73 * caller is used for the event name, the raw message is taken, the
74 * loglevel of the record and the thread ID.
77 tracepointS(formattedMessage
,
78 record
.getLoggerName(), record
.getSourceClassName(),
79 record
.getSourceMethodName(), record
.getMillis(),
80 record
.getLevel().intValue(), record
.getThreadID());
82 tracepointU(formattedMessage
,
83 record
.getLoggerName(), record
.getSourceClassName(),
84 record
.getSourceMethodName(), record
.getMillis(),
85 record
.getLevel().intValue(), record
.getThreadID());
89 /* Use for a user session daemon. */
90 private native void tracepointU(String msg
,
98 /* Use for a root session daemon. */
99 private native void tracepointS(String msg
,
This page took 0.034326 seconds and 4 git commands to generate.