JavaDoc for the logging package

This commit is contained in:
Trustin Lee 2008-08-10 07:38:28 +00:00
parent b3519dec05
commit aa2616ccce
7 changed files with 97 additions and 0 deletions

View File

@ -24,6 +24,10 @@ package org.jboss.netty.logging;
/** /**
* Logger factory which creates an
* <a href="http://commons.apache.org/logging/">Apache Commons Logging</a>
* logger.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *

View File

@ -23,6 +23,9 @@
package org.jboss.netty.logging; package org.jboss.netty.logging;
/** /**
* <em>Internal-use-only</em> logger used by Netty. <strong>DO NOT</strong>
* access this class outside of Netty.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *
@ -30,17 +33,63 @@ package org.jboss.netty.logging;
* *
*/ */
public interface InternalLogger { public interface InternalLogger {
/**
* Returns {@code true} if a DEBUG level message is logged.
*/
boolean isDebugEnabled(); boolean isDebugEnabled();
/**
* Returns {@code true} if an INFO level message is logged.
*/
boolean isInfoEnabled(); boolean isInfoEnabled();
/**
* Returns {@code true} if a WARN level message is logged.
*/
boolean isWarnEnabled(); boolean isWarnEnabled();
/**
* Returns {@code true} if an ERROR level message is logged.
*/
boolean isErrorEnabled(); boolean isErrorEnabled();
/**
* Logs a DEBUG level message.
*/
void debug(String msg); void debug(String msg);
/**
* Logs a DEBUG level message.
*/
void debug(String msg, Throwable cause); void debug(String msg, Throwable cause);
/**
* Logs an INFO level message.
*/
void info(String msg); void info(String msg);
/**
* Logs an INFO level message.
*/
void info(String msg, Throwable cause); void info(String msg, Throwable cause);
/**
* Logs a WARN level message.
*/
void warn(String msg); void warn(String msg);
/**
* Logs a WARN level message.
*/
void warn(String msg, Throwable cause); void warn(String msg, Throwable cause);
/**
* Logs an ERROR level message.
*/
void error(String msg); void error(String msg);
/**
* Logs an ERROR level message.
*/
void error(String msg, Throwable cause); void error(String msg, Throwable cause);
} }

View File

@ -23,6 +23,19 @@
package org.jboss.netty.logging; package org.jboss.netty.logging;
/** /**
* Creates an {@link InternalLogger} or changes the default factory
* implementation. This factory allows you to choose what logging framework
* Netty should use. The default factory is {@link JdkLoggerFactory}.
* You can change it to your preferred logging framework before other Netty
* classes are loaded:
* <pre>
* InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
* </pre>
* Please note that the new default factory is effective only for the classes
* which were loaded after the default factory is changed. Therefore,
* {@link #setDefaultFactory(InternalLoggerFactory)} should be called as early
* as possible and shouldn't be called more than once.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *
@ -32,10 +45,17 @@ package org.jboss.netty.logging;
public abstract class InternalLoggerFactory { public abstract class InternalLoggerFactory {
private static volatile InternalLoggerFactory defaultFactory = new JdkLoggerFactory(); private static volatile InternalLoggerFactory defaultFactory = new JdkLoggerFactory();
/**
* Returns the default factory. The initial default factory is
* {@link JdkLoggerFactory}.
*/
public static InternalLoggerFactory getDefaultFactory() { public static InternalLoggerFactory getDefaultFactory() {
return defaultFactory; return defaultFactory;
} }
/**
* Changes the default factory.
*/
public static void setDefaultFactory(InternalLoggerFactory defaultFactory) { public static void setDefaultFactory(InternalLoggerFactory defaultFactory) {
if (defaultFactory == null) { if (defaultFactory == null) {
throw new NullPointerException("defaultFactory"); throw new NullPointerException("defaultFactory");
@ -43,13 +63,22 @@ public abstract class InternalLoggerFactory {
InternalLoggerFactory.defaultFactory = defaultFactory; InternalLoggerFactory.defaultFactory = defaultFactory;
} }
/**
* Creates a new logger instance with the name of the specified class.
*/
public static InternalLogger getInstance(Class<?> clazz) { public static InternalLogger getInstance(Class<?> clazz) {
return getInstance(clazz.getName()); return getInstance(clazz.getName());
} }
/**
* Creates a new logger instance with the specified name.
*/
public static InternalLogger getInstance(String name) { public static InternalLogger getInstance(String name) {
return getDefaultFactory().newInstance(name); return getDefaultFactory().newInstance(name);
} }
/**
* Creates a new logger instance with the specified name.
*/
public abstract InternalLogger newInstance(String name); public abstract InternalLogger newInstance(String name);
} }

View File

@ -24,6 +24,10 @@ package org.jboss.netty.logging;
/** /**
* Logger factory which creates a
* <a href="http://anonsvn.jboss.org/repos/common/common-logging-spi/">JBoss Logging</a>
* logger.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *

View File

@ -25,6 +25,10 @@ package org.jboss.netty.logging;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* Logger factory which creates a
* <a href="http://java.sun.com/javase/6/docs/technotes/guides/logging/index.html">java.util.logging</a>
* logger.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *

View File

@ -24,6 +24,10 @@ package org.jboss.netty.logging;
/** /**
* Logger factory which creates an
* <a href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4J</a>
* logger.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *

View File

@ -24,6 +24,9 @@ package org.jboss.netty.logging;
/** /**
* Logger factory which creates a <a href="http://www.slf4j.org/">SLF4J</a>
* logger.
*
* @author The Netty Project (netty-dev@lists.jboss.org) * @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com) * @author Trustin Lee (tlee@redhat.com)
* *