2 * Copyright (C) 2014 - Christian Babeux <christian.babeux@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
.log4j
;
20 import java
.lang
.String
;
22 import org
.apache
.log4j
.AppenderSkeleton
;
23 import org
.apache
.log4j
.spi
.LoggingEvent
;
25 class LTTngLogAppender
extends AppenderSkeleton
{
26 private Boolean is_root
;
28 public LTTngLogAppender(Boolean isRoot
) {
30 this.is_root
= isRoot
;
32 System
.loadLibrary("lttng-ust-log4j-jni"); //$NON-NLS-1$
33 } catch (SecurityException e
) {
35 } catch (UnsatisfiedLinkError e
) {
37 } catch (NullPointerException e
) {
38 /* Should never happen */
43 public Boolean
isRoot() {
48 protected void append(LoggingEvent event
) {
52 * The line number returned from LocationInformation is a
53 * string. At least try to convert to a proper int.
56 String lineString
= event
.getLocationInformation().getLineNumber();
57 line
= Integer
.parseInt(lineString
);
58 } catch (NumberFormatException n
) {
63 tracepointS(event
.getRenderedMessage(),
64 event
.getLoggerName(),
65 event
.getLocationInformation().getClassName(),
66 event
.getLocationInformation().getMethodName(),
67 event
.getLocationInformation().getFileName(),
70 event
.getLevel().toInt(),
71 event
.getThreadName());
73 tracepointU(event
.getRenderedMessage(),
74 event
.getLoggerName(),
75 event
.getLocationInformation().getClassName(),
76 event
.getLocationInformation().getMethodName(),
77 event
.getLocationInformation().getFileName(),
80 event
.getLevel().toInt(),
81 event
.getThreadName());
86 public void close() {}
89 public boolean requiresLayout() {
93 /* Use for a user session daemon. */
94 private native void tracepointU(String msg
,
104 /* Use for a root session daemon. */
105 private native void tracepointS(String msg
,
This page took 0.030574 seconds and 4 git commands to generate.