30fac23f8c32f1837bfa1979efea6f0bdf0fb1d9
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
{
27 private Boolean isRoot
;
29 public LTTngLogAppender(Boolean isRoot
) {
33 System
.loadLibrary("lttng-ust-log4j-jni"); //$NON-NLS-1$
34 } catch (SecurityException e
) {
36 } catch (UnsatisfiedLinkError e
) {
38 } catch (NullPointerException e
) {
39 /* Should never happen */
44 public Boolean
isRoot() {
49 protected void append(LoggingEvent event
) {
53 * The line number returned from LocationInformation is a
54 * string. At least try to convert to a proper int.
57 String lineString
= event
.getLocationInformation().getLineNumber();
58 line
= Integer
.parseInt(lineString
);
59 } catch (NumberFormatException n
) {
64 tracepointS(event
.getRenderedMessage(),
65 event
.getLoggerName(),
66 event
.getLocationInformation().getClassName(),
67 event
.getLocationInformation().getMethodName(),
68 event
.getLocationInformation().getFileName(),
71 event
.getLevel().toInt(),
72 event
.getThreadName());
74 tracepointU(event
.getRenderedMessage(),
75 event
.getLoggerName(),
76 event
.getLocationInformation().getClassName(),
77 event
.getLocationInformation().getMethodName(),
78 event
.getLocationInformation().getFileName(),
81 event
.getLevel().toInt(),
82 event
.getThreadName());
87 public void close() {}
90 public boolean requiresLayout() {
94 /* Use for a user session daemon. */
95 private native void tracepointU(String msg
,
105 /* Use for a root session daemon. */
106 private native void tracepointS(String msg
,
This page took 0.035014 seconds and 4 git commands to generate.