*/
import org.lttng.ust.agent.LTTngAgent;
-public class Hello
-{
+/**
+ * Example application using the LTTng-UST Java JUL agent.
+ *
+ * @author David Goulet
+ */
+public class Hello {
+
/* Of course :) */
private static final int answer = 42;
*/
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.
import org.apache.log4j.Logger;
import org.lttng.ust.agent.LTTngAgent;
-public class Hello
-{
+/**
+ * Example application using the LTTng-UST Java JUL agent.
+ *
+ * @author Christian Babeux
+ */
+public class Hello {
+
/* Of course :) */
private static final int answer = 42;
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();
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 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) {
return numThreads;
}
-
- 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();
/**
* Execute enable handler action which is to enable the given handler
* to the received name.
+ *
+ * @param log
*/
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.
+ *
+ * @param log
*/
public void execute(LogFramework log) {
if (log.disableLogger(this.name)) {
package org.lttng.ust.agent;
-import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+/**
+ * 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;
+ /**
+ * Constructor
+ */
public LogFrameworkSkeleton() {
this.enabledLoggers = new HashMap<String, Integer>();
}
enabledLoggers.clear();
}
+ /**
+ * Get the number of enabled events.
+ *
+ * @return The number of enabled events
+ */
protected Integer getEventCount() {
return enabledLoggers.size();
}
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;
+/**
+ * JUL logging framework
+ *
+ * @author Christian Babeux
+ */
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);
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
-
import org.lttng.ust.agent.LogFrameworkSkeleton;
+/**
+ * log4j logging framework
+ *
+ * @author Christian Babeux
+ */
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);