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
;
24 import java
.util
.logging
.Handler
;
25 import java
.util
.logging
.LogManager
;
26 import java
.util
.logging
.Logger
;
28 import org
.lttng
.ust
.agent
.AbstractLttngAgent
;
31 * Agent implementation for tracing from JUL loggers.
33 * @author Alexandre Montplaisir
35 class LttngJulAgent
extends AbstractLttngAgent
<LttngLogHandler
> {
37 private static LttngJulAgent instance
= null;
39 private LttngJulAgent() {
43 public static synchronized LttngJulAgent
getInstance() {
44 if (instance
== null) {
45 instance
= new LttngJulAgent();
51 public Collection
<String
> listAvailableEvents() {
52 List
<String
> ret
= new ArrayList
<String
>();
54 List
<String
> loggersNames
= Collections
.list(LogManager
.getLogManager().getLoggerNames());
55 for (String name
: loggersNames
) {
57 * Skip the root logger. An empty string is not a valid event name
60 if (name
.equals("")) {
65 * Check if that logger has at least one LTTng JUL handler attached.
67 Logger logger
= Logger
.getLogger(name
);
68 if (hasLttngHandlerAttached(logger
)) {
76 private static boolean hasLttngHandlerAttached(Logger logger
) {
77 for (Handler handler
: logger
.getHandlers()) {
78 if (handler
instanceof LttngLogHandler
) {
This page took 0.036704 seconds and 4 git commands to generate.