2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2015 EfficiOS Inc.
5 * Copyright (C) 2015 Alexandre Montplaisir <alexmonthy@efficios.com>
8 package org
.lttng
.ust
.agent
.jul
;
10 import java
.util
.Collection
;
11 import java
.util
.Collections
;
12 import java
.util
.List
;
14 import java
.util
.TreeSet
;
15 import java
.util
.logging
.Handler
;
16 import java
.util
.logging
.LogManager
;
17 import java
.util
.logging
.Logger
;
19 import org
.lttng
.ust
.agent
.AbstractLttngAgent
;
22 * Agent implementation for tracing from JUL loggers.
24 * @author Alexandre Montplaisir
26 class LttngJulAgent
extends AbstractLttngAgent
<LttngLogHandler
> {
28 private static LttngJulAgent instance
= null;
30 private LttngJulAgent() {
34 public static synchronized LttngJulAgent
getInstance() {
35 if (instance
== null) {
36 instance
= new LttngJulAgent();
42 public Collection
<String
> listAvailableEvents() {
43 Set
<String
> ret
= new TreeSet
<String
>();
45 List
<String
> loggersNames
= Collections
.list(LogManager
.getLogManager().getLoggerNames());
46 for (String name
: loggersNames
) {
48 * Skip the root logger. An empty string is not a valid event name
51 if (name
.equals("") || name
.equals("global")) {
56 * Check if that logger has at least one LTTng JUL handler attached.
58 Logger logger
= Logger
.getLogger(name
);
59 if (hasLttngHandlerAttached(logger
)) {
67 private static boolean hasLttngHandlerAttached(Logger logger
) {
68 for (Handler handler
: logger
.getHandlers()) {
69 if (handler
instanceof LttngLogHandler
) {
75 * A parent logger, if any, may be connected to an LTTng handler. In
76 * this case, we will want to include this child logger in the output,
77 * since it will be accessible by LTTng.
79 Logger parent
= logger
.getParent();
81 return hasLttngHandlerAttached(parent
);
85 * We have reached the root logger and have not found any LTTng handler,
86 * this event will not be accessible.
This page took 0.033431 seconds and 5 git commands to generate.