Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
import org.lttng.ust.agent.LTTngAgent;
*/
import org.lttng.ust.agent.LTTngAgent;
+/**
+ * Example application using the LTTng-UST Java JUL agent.
+ *
+ * @author David Goulet
+ */
+public class Hello {
+
/* Of course :) */
private static final int answer = 42;
/* Of course :) */
private static final int answer = 42;
*/
private static LTTngAgent lttngAgent;
*/
private static LTTngAgent lttngAgent;
- public static void main(String args[]) throws Exception
- {
+ /**
+ * Application start
+ *
+ * @param args
+ * Command-line arguments
+ * @throws Exception
+ */
+ public static void main(String args[]) throws Exception {
/*
* For this example, a custom "hello" logger is created. Note that JUL
* has a default "global" that can also be used.
/*
* For this example, a custom "hello" logger is created. Note that JUL
* has a default "global" that can also be used.
import org.apache.log4j.Logger;
import org.lttng.ust.agent.LTTngAgent;
import org.apache.log4j.Logger;
import org.lttng.ust.agent.LTTngAgent;
+/**
+ * Example application using the LTTng-UST Java JUL agent.
+ *
+ * @author Christian Babeux
+ */
+public class Hello {
+
/* Of course :) */
private static final int answer = 42;
/* Of course :) */
private static final int answer = 42;
private static LTTngAgent lttngAgent;
private static LTTngAgent lttngAgent;
- public static void main(String args[]) throws Exception
- {
+ /**
+ * Application start
+ *
+ * @param args
+ * Command-line arguments
+ * @throws Exception
+ */
+ public static void main(String args[]) throws Exception {
BasicConfigurator.configure();
lttngAgent = LTTngAgent.getLTTngAgent();
BasicConfigurator.configure();
lttngAgent = LTTngAgent.getLTTngAgent();
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+/**
+ * The central agent managing the JUL and Log4j handlers.
+ *
+ * @author David Goulet
+ */
public class LTTngAgent {
/* Domains */
public class LTTngAgent {
/* Domains */
* Public getter to acquire a reference to this singleton object.
* Public getter to acquire a reference to this singleton object.
+ *
+ * @return The agent instance
+ * @throws IOException
*/
public static synchronized LTTngAgent getLTTngAgent() throws IOException {
if (curAgent == null) {
*/
public static synchronized LTTngAgent getLTTngAgent() throws IOException {
if (curAgent == null) {
-
- public void dispose() throws IOException {
+ /**
+ * Dispose the agent. Applications should call this once they are done
+ * logging.
+ */
+ public void dispose() {
if (this.useJUL) {
julUserClient.destroy();
julRootClient.destroy();
if (this.useJUL) {
julUserClient.destroy();
julRootClient.destroy();
/**
* Execute enable handler action which is to enable the given handler
* to the received name.
/**
* Execute enable handler action which is to enable the given handler
* to the received name.
*/
public void execute(LogFramework log) {
if (log.enableLogger(this.name)) {
*/
public void execute(LogFramework log) {
if (log.enableLogger(this.name)) {
/**
* Execute disable handler action which is to disable the given handler
* to the received name.
/**
* Execute disable handler action which is to disable the given handler
* to the received name.
*/
public void execute(LogFramework log) {
if (log.disableLogger(this.name)) {
*/
public void execute(LogFramework log) {
if (log.disableLogger(this.name)) {
package org.lttng.ust.agent;
package org.lttng.ust.agent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Iterator;
+/**
+ * Basic implementation of LogFramework.
+ *
+ * @author Christian Babeux
+ */
public abstract class LogFrameworkSkeleton implements LogFramework {
/* A map of event name and reference count */
private final Map<String, Integer> enabledLoggers;
public abstract class LogFrameworkSkeleton implements LogFramework {
/* A map of event name and reference count */
private final Map<String, Integer> enabledLoggers;
+ /**
+ * Constructor
+ */
public LogFrameworkSkeleton() {
this.enabledLoggers = new HashMap<String, Integer>();
}
public LogFrameworkSkeleton() {
this.enabledLoggers = new HashMap<String, Integer>();
}
enabledLoggers.clear();
}
enabledLoggers.clear();
}
+ /**
+ * Get the number of enabled events.
+ *
+ * @return The number of enabled events
+ */
protected Integer getEventCount() {
return enabledLoggers.size();
}
protected Integer getEventCount() {
return enabledLoggers.size();
}
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.lttng.ust.agent.LogFrameworkSkeleton;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.lttng.ust.agent.LogFrameworkSkeleton;
+/**
+ * JUL logging framework
+ *
+ * @author Christian Babeux
+ */
public class LTTngJUL extends LogFrameworkSkeleton {
private LTTngLogHandler handler;
private Boolean attached;
public class LTTngJUL extends LogFrameworkSkeleton {
private LTTngLogHandler handler;
private Boolean attached;
+ /**
+ * Constructor
+ *
+ * @param isRoot
+ * If this logger is a root logger or not.
+ */
public LTTngJUL(Boolean isRoot) {
super();
this.handler = new LTTngLogHandler(isRoot);
public LTTngJUL(Boolean isRoot) {
super();
this.handler = new LTTngLogHandler(isRoot);
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.lttng.ust.agent.LogFrameworkSkeleton;
import org.lttng.ust.agent.LogFrameworkSkeleton;
+/**
+ * log4j logging framework
+ *
+ * @author Christian Babeux
+ */
public class LTTngLog4j extends LogFrameworkSkeleton {
private LTTngLogAppender appender;
private Boolean attached;
public class LTTngLog4j extends LogFrameworkSkeleton {
private LTTngLogAppender appender;
private Boolean attached;
+ /**
+ * Constructor
+ *
+ * @param isRoot
+ * If this logger is a root logger or not.
+ */
public LTTngLog4j(Boolean isRoot) {
super();
this.appender = new LTTngLogAppender(isRoot);
public LTTngLog4j(Boolean isRoot) {
super();
this.appender = new LTTngLogAppender(isRoot);