2 * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@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
.util
.ArrayList
;
21 import java
.util
.Collection
;
22 import java
.util
.Collections
;
23 import java
.util
.List
;
25 import java
.util
.TreeSet
;
26 import java
.util
.logging
.Handler
;
27 import java
.util
.logging
.LogManager
;
28 import java
.util
.logging
.Logger
;
30 import org
.lttng
.ust
.agent
.AbstractLttngAgent
;
33 * Agent implementation for tracing from JUL loggers.
35 * @author Alexandre Montplaisir
37 class LttngJulAgent
extends AbstractLttngAgent
<LttngLogHandler
> {
39 private static LttngJulAgent instance
= null;
41 private LttngJulAgent() {
45 public static synchronized LttngJulAgent
getInstance() {
46 if (instance
== null) {
47 instance
= new LttngJulAgent();
53 public Collection
<String
> listAvailableEvents() {
54 Set
<String
> ret
= new TreeSet
<String
>();
56 List
<String
> loggersNames
= Collections
.list(LogManager
.getLogManager().getLoggerNames());
57 for (String name
: loggersNames
) {
59 * Skip the root logger. An empty string is not a valid event name
62 if (name
.equals("") || name
.equals("global")) {
67 * Check if that logger has at least one LTTng JUL handler attached.
69 Logger logger
= Logger
.getLogger(name
);
70 if (hasLttngHandlerAttached(logger
)) {
78 private static boolean hasLttngHandlerAttached(Logger logger
) {
79 for (Handler handler
: logger
.getHandlers()) {
80 if (handler
instanceof LttngLogHandler
) {
86 * A parent logger, if any, may be connected to an LTTng handler. In
87 * this case, we will want to include this child logger in the output,
88 * since it will be accessible by LTTng.
90 Logger parent
= logger
.getParent();
92 return hasLttngHandlerAttached(parent
);
96 * We have reached the root logger and have not found any LTTng handler,
97 * this event will not be accessible.
This page took 0.037019 seconds and 4 git commands to generate.