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
.Collection
;
21 import java
.util
.Collections
;
22 import java
.util
.List
;
24 import java
.util
.TreeSet
;
25 import java
.util
.logging
.Handler
;
26 import java
.util
.logging
.LogManager
;
27 import java
.util
.logging
.Logger
;
29 import org
.lttng
.ust
.agent
.AbstractLttngAgent
;
32 * Agent implementation for tracing from JUL loggers.
34 * @author Alexandre Montplaisir
36 class LttngJulAgent
extends AbstractLttngAgent
<LttngLogHandler
> {
38 private static LttngJulAgent instance
= null;
40 private LttngJulAgent() {
44 public static synchronized LttngJulAgent
getInstance() {
45 if (instance
== null) {
46 instance
= new LttngJulAgent();
52 public Collection
<String
> listAvailableEvents() {
53 Set
<String
> ret
= new TreeSet
<String
>();
55 List
<String
> loggersNames
= Collections
.list(LogManager
.getLogManager().getLoggerNames());
56 for (String name
: loggersNames
) {
58 * Skip the root logger. An empty string is not a valid event name
61 if (name
.equals("") || name
.equals("global")) {
66 * Check if that logger has at least one LTTng JUL handler attached.
68 Logger logger
= Logger
.getLogger(name
);
69 if (hasLttngHandlerAttached(logger
)) {
77 private static boolean hasLttngHandlerAttached(Logger logger
) {
78 for (Handler handler
: logger
.getHandlers()) {
79 if (handler
instanceof LttngLogHandler
) {
85 * A parent logger, if any, may be connected to an LTTng handler. In
86 * this case, we will want to include this child logger in the output,
87 * since it will be accessible by LTTng.
89 Logger parent
= logger
.getParent();
91 return hasLttngHandlerAttached(parent
);
95 * We have reached the root logger and have not found any LTTng handler,
96 * this event will not be accessible.
This page took 0.033257 seconds and 4 git commands to generate.