1
0

More javadoc and formatting fixes.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1432453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart
2013-01-12 15:29:22 +00:00
parent 03fced4b61
commit 592868b494
9 changed files with 97 additions and 353 deletions

View File

@@ -21,12 +21,10 @@ import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
/** /**
* <p>Implementation of commons-logging Log interface that delegates all * Implementation of commons-logging Log interface that delegates all
* logging calls to the Avalon logging abstraction: the Logger interface. * logging calls to the Avalon logging abstraction: the Logger interface.
* </p>
* <p> * <p>
* There are two ways in which this class can be used: * There are two ways in which this class can be used:
* </p>
* <ul> * <ul>
* <li>the instance can be constructed with an Avalon logger * <li>the instance can be constructed with an Avalon logger
* (by calling {@link #AvalonLogger(Logger)}). In this case, it acts * (by calling {@link #AvalonLogger(Logger)}). In this case, it acts
@@ -34,7 +32,7 @@ import org.apache.commons.logging.Log;
* particularly useful when using a property setter. * particularly useful when using a property setter.
* </li> * </li>
* <li>the {@link #setDefaultLogger} class property can be called which * <li>the {@link #setDefaultLogger} class property can be called which
* sets the ancesteral Avalon logger for this class. Any <code>AvalonLogger</code> * sets the ancestral Avalon logger for this class. Any <code>AvalonLogger</code>
* instances created through the <code>LogFactory</code> mechanisms will output * instances created through the <code>LogFactory</code> mechanisms will output
* to child loggers of this <code>Logger</code>. * to child loggers of this <code>Logger</code>.
* </li> * </li>
@@ -48,20 +46,21 @@ import org.apache.commons.logging.Log;
* commons-logging, but this never actually worked (a NullPointerException would * commons-logging, but this never actually worked (a NullPointerException would
* be thrown as soon as the deserialized object was used), so removing this marker * be thrown as soon as the deserialized object was used), so removing this marker
* is not considered to be an incompatible change. * is not considered to be an incompatible change.
* </p> *
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a> * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Id$ * @version $Id$
*/ */
public class AvalonLogger implements Log { public class AvalonLogger implements Log {
/** Ancestral Avalon logger */ /** Ancestral Avalon logger. */
private static Logger defaultLogger = null; private static Logger defaultLogger = null;
/** Avalon logger used to perform log */ /** Avalon logger used to perform log. */
private final transient Logger logger; private final transient Logger logger;
/** /**
* Constructs an <code>AvalonLogger</code> that outputs to the given * Constructs an <code>AvalonLogger</code> that outputs to the given
* <code>Logger</code> instance. * <code>Logger</code> instance.
*
* @param logger the Avalon logger implementation to delegate to * @param logger the Avalon logger implementation to delegate to
*/ */
public AvalonLogger(Logger logger) { public AvalonLogger(Logger logger) {
@@ -71,6 +70,7 @@ public class AvalonLogger implements Log {
/** /**
* Constructs an <code>AvalonLogger</code> that will log to a child * Constructs an <code>AvalonLogger</code> that will log to a child
* of the <code>Logger</code> set by calling {@link #setDefaultLogger}. * of the <code>Logger</code> set by calling {@link #setDefaultLogger}.
*
* @param name the name of the avalon logger implementation to delegate to * @param name the name of the avalon logger implementation to delegate to
*/ */
public AvalonLogger(String name) { public AvalonLogger(String name) {
@@ -81,6 +81,7 @@ public class AvalonLogger implements Log {
/** /**
* Gets the Avalon logger implementation used to perform logging. * Gets the Avalon logger implementation used to perform logging.
*
* @return avalon logger implementation * @return avalon logger implementation
*/ */
public Logger getLogger() { public Logger getLogger() {
@@ -88,8 +89,8 @@ public class AvalonLogger implements Log {
} }
/** /**
* Sets the ancesteral Avalon logger from which the delegating loggers * Sets the ancestral Avalon logger from which the delegating loggers will descend.
* will descend. *
* @param logger the default avalon logger, * @param logger the default avalon logger,
* in case there is no logger instance supplied in constructor * in case there is no logger instance supplied in constructor
*/ */
@@ -98,8 +99,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
@@ -110,8 +110,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* *
* @param message to log. * @param message to log.
* @see org.apache.commons.logging.Log#debug(Object) * @see org.apache.commons.logging.Log#debug(Object)
@@ -121,8 +120,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.error</code>.
* <code>org.apache.avalon.framework.logger.Logger.error</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
@@ -133,8 +131,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.error</code>.
* <code>org.apache.avalon.framework.logger.Logger.error</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#error(Object) * @see org.apache.commons.logging.Log#error(Object)
@@ -144,8 +141,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
* <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
* *
* @param message to log. * @param message to log.
* @param t log this cause. * @param t log this cause.
@@ -156,8 +152,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
* <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#fatal(Object) * @see org.apache.commons.logging.Log#fatal(Object)
@@ -167,8 +162,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.info</code>.
* <code>org.apache.avalon.framework.logger.Logger.info</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
@@ -179,8 +173,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.info</code>.
* <code>org.apache.avalon.framework.logger.Logger.info</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#info(Object) * @see org.apache.commons.logging.Log#info(Object)
@@ -190,8 +183,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
* @see org.apache.commons.logging.Log#isDebugEnabled() * @see org.apache.commons.logging.Log#isDebugEnabled()
*/ */
public boolean isDebugEnabled() { public boolean isDebugEnabled() {
@@ -199,8 +191,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.error</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.error</code> enabled?
* @see org.apache.commons.logging.Log#isErrorEnabled() * @see org.apache.commons.logging.Log#isErrorEnabled()
*/ */
public boolean isErrorEnabled() { public boolean isErrorEnabled() {
@@ -208,8 +199,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.fatalError</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.fatalError</code> enabled?
* @see org.apache.commons.logging.Log#isFatalEnabled() * @see org.apache.commons.logging.Log#isFatalEnabled()
*/ */
public boolean isFatalEnabled() { public boolean isFatalEnabled() {
@@ -217,8 +207,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.info</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.info</code> enabled?
* @see org.apache.commons.logging.Log#isInfoEnabled() * @see org.apache.commons.logging.Log#isInfoEnabled()
*/ */
public boolean isInfoEnabled() { public boolean isInfoEnabled() {
@@ -226,8 +215,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
* @see org.apache.commons.logging.Log#isTraceEnabled() * @see org.apache.commons.logging.Log#isTraceEnabled()
*/ */
public boolean isTraceEnabled() { public boolean isTraceEnabled() {
@@ -235,8 +223,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Is logging to * Is logging to <code>org.apache.avalon.framework.logger.Logger.warn</code> enabled?
* <code>org.apache.avalon.framework.logger.Logger.warn</code> enabled?
* @see org.apache.commons.logging.Log#isWarnEnabled() * @see org.apache.commons.logging.Log#isWarnEnabled()
*/ */
public boolean isWarnEnabled() { public boolean isWarnEnabled() {
@@ -244,8 +231,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* *
* @param message to log. * @param message to log.
* @param t log this cause. * @param t log this cause.
@@ -256,8 +242,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* <code>org.apache.avalon.framework.logger.Logger.debug</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#trace(Object) * @see org.apache.commons.logging.Log#trace(Object)
@@ -267,8 +252,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.warn</code>.
* <code>org.apache.avalon.framework.logger.Logger.warn</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
@@ -279,8 +263,7 @@ public class AvalonLogger implements Log {
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.avalon.framework.logger.Logger.warn</code>.
* <code>org.apache.avalon.framework.logger.Logger.warn</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#warn(Object) * @see org.apache.commons.logging.Log#warn(Object)
@@ -288,5 +271,4 @@ public class AvalonLogger implements Log {
public void warn(Object message) { public void warn(Object message) {
if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message)); if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message));
} }
} }

View File

@@ -15,10 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.Serializable; import java.io.Serializable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -29,7 +27,6 @@ import java.io.StringWriter;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
/** /**
* <p>Implementation of the <code>org.apache.commons.logging.Log</code> * <p>Implementation of the <code>org.apache.commons.logging.Log</code>
* interface that wraps the standard JDK logging mechanisms that are * interface that wraps the standard JDK logging mechanisms that are
@@ -44,10 +41,8 @@ import org.apache.commons.logging.Log;
*/ */
public class Jdk13LumberjackLogger implements Log, Serializable { public class Jdk13LumberjackLogger implements Log, Serializable {
// ----------------------------------------------------- Instance Variables // ----------------------------------------------------- Instance Variables
/** /**
* The underlying Logger implementation we are using. * The underlying Logger implementation we are using.
*/ */
@@ -57,7 +52,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
private String sourceMethodName = "unknown"; private String sourceMethodName = "unknown";
private boolean classAndMethodFound = false; private boolean classAndMethodFound = false;
/** /**
* This member variable simply ensures that any attempt to initialise * This member variable simply ensures that any attempt to initialise
* this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError.
@@ -68,23 +62,18 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
// ----------------------------------------------------------- Constructors // ----------------------------------------------------------- Constructors
/** /**
* Construct a named instance of this Logger. * Construct a named instance of this Logger.
* *
* @param name Name of the logger to be constructed * @param name Name of the logger to be constructed
*/ */
public Jdk13LumberjackLogger(String name) { public Jdk13LumberjackLogger(String name) {
this.name = name; this.name = name;
logger = getLogger(); logger = getLogger();
} }
// --------------------------------------------------------- Public Methods // --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) { private void log( Level level, String msg, Throwable ex ) {
if( getLogger().isLoggable(level) ) { if( getLogger().isLoggable(level) ) {
LogRecord record = new LogRecord(level, msg); LogRecord record = new LogRecord(level, msg);
@@ -101,8 +90,8 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
} }
/** /**
* <p>Gets the class and method by looking at the stack trace for the * Gets the class and method by looking at the stack trace for the
* first entry that is not this class.</p> * first entry that is not this class.
*/ */
private void getClassAndMethod() { private void getClassAndMethod() {
try { try {
@@ -144,7 +133,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.FINE, String.valueOf(message), null); log(Level.FINE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINE</code>. * Logs a message with <code>java.util.logging.Level.FINE</code>.
* *
@@ -156,7 +144,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.FINE, String.valueOf(message), exception); log(Level.FINE, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -167,7 +154,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), null); log(Level.SEVERE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -179,7 +165,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), exception); log(Level.SEVERE, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -190,7 +175,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), null); log(Level.SEVERE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -202,7 +186,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), exception); log(Level.SEVERE, String.valueOf(message), exception);
} }
/** /**
* Return the native Logger instance we are using. * Return the native Logger instance we are using.
*/ */
@@ -213,7 +196,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return logger; return logger;
} }
/** /**
* Logs a message with <code>java.util.logging.Level.INFO</code>. * Logs a message with <code>java.util.logging.Level.INFO</code>.
* *
@@ -224,7 +206,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.INFO, String.valueOf(message), null); log(Level.INFO, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.INFO</code>. * Logs a message with <code>java.util.logging.Level.INFO</code>.
* *
@@ -236,7 +217,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.INFO, String.valueOf(message), exception); log(Level.INFO, String.valueOf(message), exception);
} }
/** /**
* Is debug logging currently enabled? * Is debug logging currently enabled?
*/ */
@@ -244,7 +224,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.FINE); return getLogger().isLoggable(Level.FINE);
} }
/** /**
* Is error logging currently enabled? * Is error logging currently enabled?
*/ */
@@ -252,7 +231,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.SEVERE); return getLogger().isLoggable(Level.SEVERE);
} }
/** /**
* Is fatal logging currently enabled? * Is fatal logging currently enabled?
*/ */
@@ -260,7 +238,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.SEVERE); return getLogger().isLoggable(Level.SEVERE);
} }
/** /**
* Is info logging currently enabled? * Is info logging currently enabled?
*/ */
@@ -268,7 +245,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.INFO); return getLogger().isLoggable(Level.INFO);
} }
/** /**
* Is trace logging currently enabled? * Is trace logging currently enabled?
*/ */
@@ -276,7 +252,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.FINEST); return getLogger().isLoggable(Level.FINEST);
} }
/** /**
* Is warn logging currently enabled? * Is warn logging currently enabled?
*/ */
@@ -284,7 +259,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
return getLogger().isLoggable(Level.WARNING); return getLogger().isLoggable(Level.WARNING);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINEST</code>. * Logs a message with <code>java.util.logging.Level.FINEST</code>.
* *
@@ -295,7 +269,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.FINEST, String.valueOf(message), null); log(Level.FINEST, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINEST</code>. * Logs a message with <code>java.util.logging.Level.FINEST</code>.
* *
@@ -307,7 +280,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.FINEST, String.valueOf(message), exception); log(Level.FINEST, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.WARNING</code>. * Logs a message with <code>java.util.logging.Level.WARNING</code>.
* *
@@ -318,7 +290,6 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
log(Level.WARNING, String.valueOf(message), null); log(Level.WARNING, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.WARNING</code>. * Logs a message with <code>java.util.logging.Level.WARNING</code>.
* *
@@ -329,6 +300,4 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
public void warn(Object message, Throwable exception) { public void warn(Object message, Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception); log(Level.WARNING, String.valueOf(message), exception);
} }
} }

View File

@@ -15,21 +15,18 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.Serializable; import java.io.Serializable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
/** /**
* <p>Implementation of the <code>org.apache.commons.logging.Log</code> * Implementation of the <code>org.apache.commons.logging.Log</code>
* interface that wraps the standard JDK logging mechanisms that were * interface that wraps the standard JDK logging mechanisms that were
* introduced in the Merlin release (JDK 1.4).</p> * introduced in the Merlin release (JDK 1.4).
* *
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a> * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a> * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
@@ -48,39 +45,31 @@ public class Jdk14Logger implements Log, Serializable {
// ----------------------------------------------------------- Constructors // ----------------------------------------------------------- Constructors
/** /**
* Construct a named instance of this Logger. * Construct a named instance of this Logger.
* *
* @param name Name of the logger to be constructed * @param name Name of the logger to be constructed
*/ */
public Jdk14Logger(String name) { public Jdk14Logger(String name) {
this.name = name; this.name = name;
logger = getLogger(); logger = getLogger();
} }
// ----------------------------------------------------- Instance Variables // ----------------------------------------------------- Instance Variables
/** /**
* The underlying Logger implementation we are using. * The underlying Logger implementation we are using.
*/ */
protected transient Logger logger = null; protected transient Logger logger = null;
/** /**
* The name of the logger we are wrapping. * The name of the logger we are wrapping.
*/ */
protected String name = null; protected String name = null;
// --------------------------------------------------------- Public Methods // --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) { private void log( Level level, String msg, Throwable ex ) {
Logger logger = getLogger(); Logger logger = getLogger();
if (logger.isLoggable(level)) { if (logger.isLoggable(level)) {
// Hack (?) to get the stack trace. // Hack (?) to get the stack trace.
@@ -100,7 +89,6 @@ public class Jdk14Logger implements Log, Serializable {
logger.logp( level, cname, method, msg, ex ); logger.logp( level, cname, method, msg, ex );
} }
} }
} }
/** /**
@@ -113,7 +101,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.FINE, String.valueOf(message), null); log(Level.FINE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINE</code>. * Logs a message with <code>java.util.logging.Level.FINE</code>.
* *
@@ -125,7 +112,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.FINE, String.valueOf(message), exception); log(Level.FINE, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -136,7 +122,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), null); log(Level.SEVERE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -148,7 +133,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), exception); log(Level.SEVERE, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -159,7 +143,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), null); log(Level.SEVERE, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.SEVERE</code>. * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
* *
@@ -171,7 +154,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.SEVERE, String.valueOf(message), exception); log(Level.SEVERE, String.valueOf(message), exception);
} }
/** /**
* Return the native Logger instance we are using. * Return the native Logger instance we are using.
*/ */
@@ -182,7 +164,6 @@ public class Jdk14Logger implements Log, Serializable {
return logger; return logger;
} }
/** /**
* Logs a message with <code>java.util.logging.Level.INFO</code>. * Logs a message with <code>java.util.logging.Level.INFO</code>.
* *
@@ -193,7 +174,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.INFO, String.valueOf(message), null); log(Level.INFO, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.INFO</code>. * Logs a message with <code>java.util.logging.Level.INFO</code>.
* *
@@ -205,7 +185,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.INFO, String.valueOf(message), exception); log(Level.INFO, String.valueOf(message), exception);
} }
/** /**
* Is debug logging currently enabled? * Is debug logging currently enabled?
*/ */
@@ -213,7 +192,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.FINE); return getLogger().isLoggable(Level.FINE);
} }
/** /**
* Is error logging currently enabled? * Is error logging currently enabled?
*/ */
@@ -221,7 +199,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.SEVERE); return getLogger().isLoggable(Level.SEVERE);
} }
/** /**
* Is fatal logging currently enabled? * Is fatal logging currently enabled?
*/ */
@@ -229,7 +206,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.SEVERE); return getLogger().isLoggable(Level.SEVERE);
} }
/** /**
* Is info logging currently enabled? * Is info logging currently enabled?
*/ */
@@ -237,7 +213,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.INFO); return getLogger().isLoggable(Level.INFO);
} }
/** /**
* Is trace logging currently enabled? * Is trace logging currently enabled?
*/ */
@@ -245,7 +220,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.FINEST); return getLogger().isLoggable(Level.FINEST);
} }
/** /**
* Is warn logging currently enabled? * Is warn logging currently enabled?
*/ */
@@ -253,7 +227,6 @@ public class Jdk14Logger implements Log, Serializable {
return getLogger().isLoggable(Level.WARNING); return getLogger().isLoggable(Level.WARNING);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINEST</code>. * Logs a message with <code>java.util.logging.Level.FINEST</code>.
* *
@@ -264,7 +237,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.FINEST, String.valueOf(message), null); log(Level.FINEST, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.FINEST</code>. * Logs a message with <code>java.util.logging.Level.FINEST</code>.
* *
@@ -276,7 +248,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.FINEST, String.valueOf(message), exception); log(Level.FINEST, String.valueOf(message), exception);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.WARNING</code>. * Logs a message with <code>java.util.logging.Level.WARNING</code>.
* *
@@ -287,7 +258,6 @@ public class Jdk14Logger implements Log, Serializable {
log(Level.WARNING, String.valueOf(message), null); log(Level.WARNING, String.valueOf(message), null);
} }
/** /**
* Logs a message with <code>java.util.logging.Level.WARNING</code>. * Logs a message with <code>java.util.logging.Level.WARNING</code>.
* *
@@ -298,6 +268,4 @@ public class Jdk14Logger implements Log, Serializable {
public void warn(Object message, Throwable exception) { public void warn(Object message, Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception); log(Level.WARNING, String.valueOf(message), exception);
} }
} }

View File

@@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.Serializable; import java.io.Serializable;
@@ -95,14 +94,12 @@ public class Log4JLogger implements Log, Serializable {
traceLevel = _traceLevel; traceLevel = _traceLevel;
} }
// ------------------------------------------------------------ Constructor // ------------------------------------------------------------ Constructor
public Log4JLogger() { public Log4JLogger() {
name = null; name = null;
} }
/** /**
* Base constructor. * Base constructor.
*/ */
@@ -123,7 +120,6 @@ public class Log4JLogger implements Log, Serializable {
this.logger=logger; this.logger=logger;
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.TRACE</code>. * Logs a message with <code>org.apache.log4j.Priority.TRACE</code>.
* When using a log4j version that does not support the <code>TRACE</code> * When using a log4j version that does not support the <code>TRACE</code>
@@ -136,7 +132,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, traceLevel, message, null ); getLogger().log(FQCN, traceLevel, message, null );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.TRACE</code>. * Logs a message with <code>org.apache.log4j.Priority.TRACE</code>.
* When using a log4j version that does not support the <code>TRACE</code> * When using a log4j version that does not support the <code>TRACE</code>
@@ -150,7 +145,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, traceLevel, message, t ); getLogger().log(FQCN, traceLevel, message, t );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.DEBUG</code>. * Logs a message with <code>org.apache.log4j.Priority.DEBUG</code>.
* *
@@ -172,7 +166,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.DEBUG, message, t ); getLogger().log(FQCN, Level.DEBUG, message, t );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.INFO</code>. * Logs a message with <code>org.apache.log4j.Priority.INFO</code>.
* *
@@ -183,7 +176,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.INFO, message, null ); getLogger().log(FQCN, Level.INFO, message, null );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.INFO</code>. * Logs a message with <code>org.apache.log4j.Priority.INFO</code>.
* *
@@ -195,7 +187,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.INFO, message, t ); getLogger().log(FQCN, Level.INFO, message, t );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.WARN</code>. * Logs a message with <code>org.apache.log4j.Priority.WARN</code>.
* *
@@ -206,7 +197,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.WARN, message, null ); getLogger().log(FQCN, Level.WARN, message, null );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.WARN</code>. * Logs a message with <code>org.apache.log4j.Priority.WARN</code>.
* *
@@ -218,7 +208,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.WARN, message, t ); getLogger().log(FQCN, Level.WARN, message, t );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.ERROR</code>. * Logs a message with <code>org.apache.log4j.Priority.ERROR</code>.
* *
@@ -229,7 +218,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.ERROR, message, null ); getLogger().log(FQCN, Level.ERROR, message, null );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.ERROR</code>. * Logs a message with <code>org.apache.log4j.Priority.ERROR</code>.
* *
@@ -241,7 +229,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.ERROR, message, t ); getLogger().log(FQCN, Level.ERROR, message, t );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.FATAL</code>. * Logs a message with <code>org.apache.log4j.Priority.FATAL</code>.
* *
@@ -252,7 +239,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.FATAL, message, null ); getLogger().log(FQCN, Level.FATAL, message, null );
} }
/** /**
* Logs a message with <code>org.apache.log4j.Priority.FATAL</code>. * Logs a message with <code>org.apache.log4j.Priority.FATAL</code>.
* *
@@ -264,7 +250,6 @@ public class Log4JLogger implements Log, Serializable {
getLogger().log(FQCN, Level.FATAL, message, t ); getLogger().log(FQCN, Level.FATAL, message, t );
} }
/** /**
* Return the native Logger instance we are using. * Return the native Logger instance we are using.
*/ */
@@ -275,7 +260,6 @@ public class Log4JLogger implements Log, Serializable {
return this.logger; return this.logger;
} }
/** /**
* Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority. * Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority.
*/ */
@@ -283,7 +267,6 @@ public class Log4JLogger implements Log, Serializable {
return getLogger().isDebugEnabled(); return getLogger().isDebugEnabled();
} }
/** /**
* Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority. * Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority.
*/ */
@@ -291,7 +274,6 @@ public class Log4JLogger implements Log, Serializable {
return getLogger().isEnabledFor(Level.ERROR); return getLogger().isEnabledFor(Level.ERROR);
} }
/** /**
* Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority. * Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority.
*/ */
@@ -299,7 +281,6 @@ public class Log4JLogger implements Log, Serializable {
return getLogger().isEnabledFor(Level.FATAL); return getLogger().isEnabledFor(Level.FATAL);
} }
/** /**
* Check whether the Log4j Logger used is enabled for <code>INFO</code> priority. * Check whether the Log4j Logger used is enabled for <code>INFO</code> priority.
*/ */
@@ -307,7 +288,6 @@ public class Log4JLogger implements Log, Serializable {
return getLogger().isInfoEnabled(); return getLogger().isInfoEnabled();
} }
/** /**
* Check whether the Log4j Logger used is enabled for <code>TRACE</code> priority. * Check whether the Log4j Logger used is enabled for <code>TRACE</code> priority.
* When using a log4j version that does not support the TRACE level, this call * When using a log4j version that does not support the TRACE level, this call

View File

@@ -17,7 +17,6 @@
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@@ -30,7 +29,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
/** /**
* <p>Concrete subclass of {@link LogFactory} that implements the * <p>Concrete subclass of {@link LogFactory} that implements the
* following algorithm to dynamically select a logging implementation * following algorithm to dynamically select a logging implementation
@@ -67,7 +65,6 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class LogFactoryImpl extends LogFactory { public class LogFactoryImpl extends LogFactory {
/** Log4JLogger class name */ /** Log4JLogger class name */
private static final String LOGGING_IMPL_LOG4J_LOGGER = "org.apache.commons.logging.impl.Log4JLogger"; private static final String LOGGING_IMPL_LOG4J_LOGGER = "org.apache.commons.logging.impl.Log4JLogger";
/** Jdk14Logger class name */ /** Jdk14Logger class name */
@@ -82,8 +79,6 @@ public class LogFactoryImpl extends LogFactory {
// ----------------------------------------------------------- Constructors // ----------------------------------------------------------- Constructors
/** /**
* Public no-arguments constructor required by the lookup mechanism. * Public no-arguments constructor required by the lookup mechanism.
*/ */
@@ -95,24 +90,19 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
// ----------------------------------------------------- Manifest Constants // ----------------------------------------------------- Manifest Constants
/** /**
* The name (<code>org.apache.commons.logging.Log</code>) of the system * The name (<code>org.apache.commons.logging.Log</code>) of the system
* property identifying our {@link Log} implementation class. * property identifying our {@link Log} implementation class.
*/ */
public static final String LOG_PROPERTY = public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
"org.apache.commons.logging.Log";
/** /**
* The deprecated system property used for backwards compatibility with * The deprecated system property used for backwards compatibility with
* old versions of JCL. * old versions of JCL.
*/ */
protected static final String LOG_PROPERTY_OLD = protected static final String LOG_PROPERTY_OLD = "org.apache.commons.logging.log";
"org.apache.commons.logging.log";
/** /**
* The name (<code>org.apache.commons.logging.Log.allowFlawedContext</code>) * The name (<code>org.apache.commons.logging.Log.allowFlawedContext</code>)
@@ -161,7 +151,6 @@ public class LogFactoryImpl extends LogFactory {
public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY = public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY =
"org.apache.commons.logging.Log.allowFlawedHierarchy"; "org.apache.commons.logging.Log.allowFlawedHierarchy";
/** /**
* The names of classes that will be tried (in order) as logging * The names of classes that will be tried (in order) as logging
* adapters. Each class is expected to implement the Log interface, * adapters. Each class is expected to implement the Log interface,
@@ -177,7 +166,6 @@ public class LogFactoryImpl extends LogFactory {
"org.apache.commons.logging.impl.SimpleLog" "org.apache.commons.logging.impl.SimpleLog"
}; };
// ----------------------------------------------------- Instance Variables // ----------------------------------------------------- Instance Variables
/** /**
@@ -191,26 +179,22 @@ public class LogFactoryImpl extends LogFactory {
*/ */
private String diagnosticPrefix; private String diagnosticPrefix;
/** /**
* Configuration attributes. * Configuration attributes.
*/ */
protected Hashtable attributes = new Hashtable(); protected Hashtable attributes = new Hashtable();
/** /**
* The {@link org.apache.commons.logging.Log} instances that have * The {@link org.apache.commons.logging.Log} instances that have
* already been created, keyed by logger name. * already been created, keyed by logger name.
*/ */
protected Hashtable instances = new Hashtable(); protected Hashtable instances = new Hashtable();
/** /**
* Name of the class implementing the Log interface. * Name of the class implementing the Log interface.
*/ */
private String logClassName; private String logClassName;
/** /**
* The one-argument constructor of the * The one-argument constructor of the
* {@link org.apache.commons.logging.Log} * {@link org.apache.commons.logging.Log}
@@ -220,13 +204,10 @@ public class LogFactoryImpl extends LogFactory {
*/ */
protected Constructor logConstructor = null; protected Constructor logConstructor = null;
/** /**
* The signature of the Constructor to be used. * The signature of the Constructor to be used.
*/ */
protected Class logConstructorSignature[] = protected Class logConstructorSignature[] = { java.lang.String.class };
{ java.lang.String.class };
/** /**
* The one-argument <code>setLogFactory</code> method of the selected * The one-argument <code>setLogFactory</code> method of the selected
@@ -234,12 +215,10 @@ public class LogFactoryImpl extends LogFactory {
*/ */
protected Method logMethod = null; protected Method logMethod = null;
/** /**
* The signature of the <code>setLogFactory</code> method to be used. * The signature of the <code>setLogFactory</code> method to be used.
*/ */
protected Class logMethodSignature[] = protected Class logMethodSignature[] = { LogFactory.class };
{ LogFactory.class };
/** /**
* See getBaseClassLoader and initConfiguration. * See getBaseClassLoader and initConfiguration.
@@ -258,7 +237,6 @@ public class LogFactoryImpl extends LogFactory {
// --------------------------------------------------------- Public Methods // --------------------------------------------------------- Public Methods
/** /**
* Return the configuration attribute with the specified name (if any), * Return the configuration attribute with the specified name (if any),
* or <code>null</code> if there is no such attribute. * or <code>null</code> if there is no such attribute.
@@ -266,12 +244,9 @@ public class LogFactoryImpl extends LogFactory {
* @param name Name of the attribute to return * @param name Name of the attribute to return
*/ */
public Object getAttribute(String name) { public Object getAttribute(String name) {
return attributes.get(name); return attributes.get(name);
} }
/** /**
* Return an array containing the names of all currently defined * Return an array containing the names of all currently defined
* configuration attributes. If there are no such attributes, a zero * configuration attributes. If there are no such attributes, a zero
@@ -281,7 +256,6 @@ public class LogFactoryImpl extends LogFactory {
return (String[]) attributes.keySet().toArray(new String[attributes.size()]); return (String[]) attributes.keySet().toArray(new String[attributes.size()]);
} }
/** /**
* Convenience method to derive a name from the specified class and * Convenience method to derive a name from the specified class and
* call <code>getInstance(String)</code> with it. * call <code>getInstance(String)</code> with it.
@@ -292,12 +266,9 @@ public class LogFactoryImpl extends LogFactory {
* instance cannot be returned * instance cannot be returned
*/ */
public Log getInstance(Class clazz) throws LogConfigurationException { public Log getInstance(Class clazz) throws LogConfigurationException {
return getInstance(clazz.getName()); return getInstance(clazz.getName());
} }
/** /**
* <p>Construct (if necessary) and return a <code>Log</code> instance, * <p>Construct (if necessary) and return a <code>Log</code> instance,
* using the factory's current set of configuration attributes.</p> * using the factory's current set of configuration attributes.</p>
@@ -316,17 +287,14 @@ public class LogFactoryImpl extends LogFactory {
* instance cannot be returned * instance cannot be returned
*/ */
public Log getInstance(String name) throws LogConfigurationException { public Log getInstance(String name) throws LogConfigurationException {
Log instance = (Log) instances.get(name); Log instance = (Log) instances.get(name);
if (instance == null) { if (instance == null) {
instance = newInstance(name); instance = newInstance(name);
instances.put(name, instance); instances.put(name, instance);
} }
return instance; return instance;
} }
/** /**
* Release any internal references to previously created * Release any internal references to previously created
* {@link org.apache.commons.logging.Log} * {@link org.apache.commons.logging.Log}
@@ -341,7 +309,6 @@ public class LogFactoryImpl extends LogFactory {
instances.clear(); instances.clear();
} }
/** /**
* Remove any configuration attribute associated with the specified name. * Remove any configuration attribute associated with the specified name.
* If there is no such attribute, no action is taken. * If there is no such attribute, no action is taken.
@@ -349,12 +316,9 @@ public class LogFactoryImpl extends LogFactory {
* @param name Name of the attribute to remove * @param name Name of the attribute to remove
*/ */
public void removeAttribute(String name) { public void removeAttribute(String name) {
attributes.remove(name); attributes.remove(name);
} }
/** /**
* Set the configuration attribute with the specified name. Calling * Set the configuration attribute with the specified name. Calling
* this with a <code>null</code> value is equivalent to calling * this with a <code>null</code> value is equivalent to calling
@@ -380,7 +344,6 @@ public class LogFactoryImpl extends LogFactory {
* to remove any setting for this attribute * to remove any setting for this attribute
*/ */
public void setAttribute(String name, Object value) { public void setAttribute(String name, Object value) {
if (logConstructor != null) { if (logConstructor != null) {
logDiagnostic("setAttribute: call too late; configuration already performed."); logDiagnostic("setAttribute: call too late; configuration already performed.");
} }
@@ -394,10 +357,8 @@ public class LogFactoryImpl extends LogFactory {
if (name.equals(TCCL_KEY)) { if (name.equals(TCCL_KEY)) {
useTCCL = value != null && Boolean.valueOf(value.toString()).booleanValue(); useTCCL = value != null && Boolean.valueOf(value.toString()).booleanValue();
} }
} }
// ------------------------------------------------------ // ------------------------------------------------------
// Static Methods // Static Methods
// //
@@ -414,7 +375,6 @@ public class LogFactoryImpl extends LogFactory {
return LogFactory.getContextClassLoader(); return LogFactory.getContextClassLoader();
} }
/** /**
* Workaround for bug in Java1.2; in theory this method is not needed. * Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.isDiagnosticsEnabled. * See LogFactory.isDiagnosticsEnabled.
@@ -423,7 +383,6 @@ public class LogFactoryImpl extends LogFactory {
return LogFactory.isDiagnosticsEnabled(); return LogFactory.isDiagnosticsEnabled();
} }
/** /**
* Workaround for bug in Java1.2; in theory this method is not needed. * Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader. * See LogFactory.getClassLoader.
@@ -433,7 +392,6 @@ public class LogFactoryImpl extends LogFactory {
return LogFactory.getClassLoader(clazz); return LogFactory.getClassLoader(clazz);
} }
// ------------------------------------------------------ Protected Methods // ------------------------------------------------------ Protected Methods
/** /**
@@ -473,7 +431,6 @@ public class LogFactoryImpl extends LogFactory {
diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] "; diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] ";
} }
/** /**
* Output a diagnostic message to a user-specified destination (if the * Output a diagnostic message to a user-specified destination (if the
* user has enabled diagnostic logging). * user has enabled diagnostic logging).
@@ -495,7 +452,6 @@ public class LogFactoryImpl extends LogFactory {
* it will be. * it will be.
*/ */
protected String getLogClassName() { protected String getLogClassName() {
if (logClassName == null) { if (logClassName == null) {
discoverLogImplementation(getClass().getName()); discoverLogImplementation(getClass().getName());
} }
@@ -530,7 +486,6 @@ public class LogFactoryImpl extends LogFactory {
return logConstructor; return logConstructor;
} }
/** /**
* Is <em>JDK 1.3 with Lumberjack</em> logging available? * Is <em>JDK 1.3 with Lumberjack</em> logging available?
* *
@@ -543,7 +498,6 @@ public class LogFactoryImpl extends LogFactory {
"org.apache.commons.logging.impl.Jdk13LumberjackLogger"); "org.apache.commons.logging.impl.Jdk13LumberjackLogger");
} }
/** /**
* <p>Return <code>true</code> if <em>JDK 1.4 or later</em> logging * <p>Return <code>true</code> if <em>JDK 1.4 or later</em> logging
* is available. Also checks that the <code>Throwable</code> class * is available. Also checks that the <code>Throwable</code> class
@@ -559,7 +513,6 @@ public class LogFactoryImpl extends LogFactory {
"org.apache.commons.logging.impl.Jdk14Logger"); "org.apache.commons.logging.impl.Jdk14Logger");
} }
/** /**
* Is a <em>Log4J</em> implementation available? * Is a <em>Log4J</em> implementation available?
* *
@@ -572,7 +525,6 @@ public class LogFactoryImpl extends LogFactory {
LOGGING_IMPL_LOG4J_LOGGER); LOGGING_IMPL_LOG4J_LOGGER);
} }
/** /**
* Create and return a new {@link org.apache.commons.logging.Log} * Create and return a new {@link org.apache.commons.logging.Log}
* instance for the specified name. * instance for the specified name.
@@ -583,7 +535,6 @@ public class LogFactoryImpl extends LogFactory {
* be created * be created
*/ */
protected Log newInstance(String name) throws LogConfigurationException { protected Log newInstance(String name) throws LogConfigurationException {
Log instance; Log instance;
try { try {
if (logConstructor == null) { if (logConstructor == null) {
@@ -620,7 +571,6 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
// ------------------------------------------------------ Private Methods // ------------------------------------------------------ Private Methods
/** /**
@@ -807,7 +757,6 @@ public class LogFactoryImpl extends LogFactory {
allowFlawedHierarchy = getBooleanConfiguration(ALLOW_FLAWED_HIERARCHY_PROPERTY, true); allowFlawedHierarchy = getBooleanConfiguration(ALLOW_FLAWED_HIERARCHY_PROPERTY, true);
} }
/** /**
* Attempts to create a Log instance for the given category name. * Attempts to create a Log instance for the given category name.
* Follows the discovery process described in the class javadoc. * Follows the discovery process described in the class javadoc.
@@ -818,8 +767,7 @@ public class LogFactoryImpl extends LogFactory {
* or if no adapter at all can be instantiated * or if no adapter at all can be instantiated
*/ */
private Log discoverLogImplementation(String logCategory) private Log discoverLogImplementation(String logCategory)
throws LogConfigurationException throws LogConfigurationException {
{
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Discovering a Log implementation..."); logDiagnostic("Discovering a Log implementation...");
} }
@@ -902,7 +850,6 @@ public class LogFactoryImpl extends LogFactory {
return result; return result;
} }
/** /**
* Appends message if the given name is similar to the candidate. * Appends message if the given name is similar to the candidate.
* @param messageBuffer <code>StringBuffer</code> the message should be appended to, * @param messageBuffer <code>StringBuffer</code> the message should be appended to,
@@ -928,7 +875,6 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
/** /**
* Checks system properties and the attribute map for * Checks system properties and the attribute map for
* a Log implementation specified by the user under the * a Log implementation specified by the user under the
@@ -936,8 +882,7 @@ public class LogFactoryImpl extends LogFactory {
* *
* @return classname specified by the user, or <code>null</code> * @return classname specified by the user, or <code>null</code>
*/ */
private String findUserSpecifiedLogClassName() private String findUserSpecifiedLogClassName() {
{
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Trying to get log class from attribute '" + LOG_PROPERTY + "'"); logDiagnostic("Trying to get log class from attribute '" + LOG_PROPERTY + "'");
} }
@@ -991,7 +936,6 @@ public class LogFactoryImpl extends LogFactory {
return specifiedClass; return specifiedClass;
} }
/** /**
* Attempts to load the given class, find a suitable constructor, * Attempts to load the given class, find a suitable constructor,
* and instantiate an instance of Log. * and instantiate an instance of Log.
@@ -1196,7 +1140,6 @@ public class LogFactoryImpl extends LogFactory {
return logAdapter; return logAdapter;
} }
/** /**
* Return the classloader from which we should try to load the logging * Return the classloader from which we should try to load the logging
* adapter classes. * adapter classes.
@@ -1374,7 +1317,6 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
/** /**
* Report a problem loading the log adapter, then either return * Report a problem loading the log adapter, then either return
* (if the situation is considered recoverable) or throw a * (if the situation is considered recoverable) or throw a

View File

@@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.Serializable; import java.io.Serializable;
@@ -24,14 +23,13 @@ import org.apache.log.Hierarchy;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
/** /**
* <p>Implementation of <code>org.apache.commons.logging.Log</code> * Implementation of <code>org.apache.commons.logging.Log</code>
* that wraps the <a href="http://avalon.apache.org/logkit/">avalon-logkit</a> * that wraps the <a href="http://avalon.apache.org/logkit/">avalon-logkit</a>
* logging system. Configuration of <code>LogKit</code> is left to the user. * logging system. Configuration of <code>LogKit</code> is left to the user.
* </p> * <p>
* * <code>LogKit</code> accepts only <code>String</code> messages.
* <p><code>LogKit</code> accepts only <code>String</code> messages.
* Therefore, this implementation converts object messages into strings * Therefore, this implementation converts object messages into strings
* by called their <code>toString()</code> method before logging them.</p> * by called their <code>toString()</code> method before logging them.
* *
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a> * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Robert Burrell Donkin * @author Robert Burrell Donkin
@@ -39,20 +37,16 @@ import org.apache.commons.logging.Log;
*/ */
public class LogKitLogger implements Log, Serializable { public class LogKitLogger implements Log, Serializable {
// ------------------------------------------------------------- Attributes // ------------------------------------------------------------- Attributes
/** Logging goes to this <code>LogKit</code> logger */ /** Logging goes to this <code>LogKit</code> logger */
protected transient Logger logger = null; protected transient Logger logger = null;
/** Name of this logger */ /** Name of this logger */
protected String name = null; protected String name = null;
// ------------------------------------------------------------ Constructor // ------------------------------------------------------------ Constructor
/** /**
* Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code> * Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code>
* logger with given name. * logger with given name.
@@ -64,12 +58,10 @@ public class LogKitLogger implements Log, Serializable {
this.logger = getLogger(); this.logger = getLogger();
} }
// --------------------------------------------------------- Public Methods // --------------------------------------------------------- Public Methods
/** /**
* <p>Return the underlying Logger we are using.</p> * Return the underlying Logger we are using.
*/ */
public Logger getLogger() { public Logger getLogger() {
@@ -80,10 +72,8 @@ public class LogKitLogger implements Log, Serializable {
} }
// ----------------------------------------------------- Log Implementation // ----------------------------------------------------- Log Implementation
/** /**
* Logs a message with <code>org.apache.log.Priority.DEBUG</code>. * Logs a message with <code>org.apache.log.Priority.DEBUG</code>.
* *
@@ -94,7 +84,6 @@ public class LogKitLogger implements Log, Serializable {
debug(message); debug(message);
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.DEBUG</code>. * Logs a message with <code>org.apache.log.Priority.DEBUG</code>.
* *
@@ -106,7 +95,6 @@ public class LogKitLogger implements Log, Serializable {
debug(message, t); debug(message, t);
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.DEBUG</code>. * Logs a message with <code>org.apache.log.Priority.DEBUG</code>.
* *
@@ -119,7 +107,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.DEBUG</code>. * Logs a message with <code>org.apache.log.Priority.DEBUG</code>.
* *
@@ -133,7 +120,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.INFO</code>. * Logs a message with <code>org.apache.log.Priority.INFO</code>.
* *
@@ -146,7 +132,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.INFO</code>. * Logs a message with <code>org.apache.log.Priority.INFO</code>.
* *
@@ -160,7 +145,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.WARN</code>. * Logs a message with <code>org.apache.log.Priority.WARN</code>.
* *
@@ -173,7 +157,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.WARN</code>. * Logs a message with <code>org.apache.log.Priority.WARN</code>.
* *
@@ -187,7 +170,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.ERROR</code>. * Logs a message with <code>org.apache.log.Priority.ERROR</code>.
* *
@@ -200,7 +182,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.ERROR</code>. * Logs a message with <code>org.apache.log.Priority.ERROR</code>.
* *
@@ -214,7 +195,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.FATAL_ERROR</code>. * Logs a message with <code>org.apache.log.Priority.FATAL_ERROR</code>.
* *
@@ -227,7 +207,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Logs a message with <code>org.apache.log.Priority.FATAL_ERROR</code>. * Logs a message with <code>org.apache.log.Priority.FATAL_ERROR</code>.
* *
@@ -241,7 +220,6 @@ public class LogKitLogger implements Log, Serializable {
} }
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
*/ */
@@ -249,7 +227,6 @@ public class LogKitLogger implements Log, Serializable {
return getLogger().isDebugEnabled(); return getLogger().isDebugEnabled();
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>ERROR</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>ERROR</code>.
*/ */
@@ -257,7 +234,6 @@ public class LogKitLogger implements Log, Serializable {
return getLogger().isErrorEnabled(); return getLogger().isErrorEnabled();
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>FATAL_ERROR</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>FATAL_ERROR</code>.
*/ */
@@ -265,7 +241,6 @@ public class LogKitLogger implements Log, Serializable {
return getLogger().isFatalErrorEnabled(); return getLogger().isFatalErrorEnabled();
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>INFO</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>INFO</code>.
*/ */
@@ -273,7 +248,6 @@ public class LogKitLogger implements Log, Serializable {
return getLogger().isInfoEnabled(); return getLogger().isInfoEnabled();
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
*/ */
@@ -281,13 +255,10 @@ public class LogKitLogger implements Log, Serializable {
return getLogger().isDebugEnabled(); return getLogger().isDebugEnabled();
} }
/** /**
* Checks whether the <code>LogKit</code> logger will log messages of priority <code>WARN</code>. * Checks whether the <code>LogKit</code> logger will log messages of priority <code>WARN</code>.
*/ */
public boolean isWarnEnabled() { public boolean isWarnEnabled() {
return getLogger().isWarnEnabled(); return getLogger().isWarnEnabled();
} }
} }

View File

@@ -15,17 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.Serializable; import java.io.Serializable;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
/** /**
* <p>Trivial implementation of Log that throws away all messages. No * Trivial implementation of Log that throws away all messages. No
* configurable system properties are supported.</p> * configurable system properties are supported.
* *
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a> * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff * @author Rod Waldhoff
@@ -103,5 +100,4 @@ public class NoOpLog implements Log, Serializable {
* @return false * @return false
*/ */
public final boolean isWarnEnabled() { return false; } public final boolean isWarnEnabled() { return false; }
} }

View File

@@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@@ -26,7 +25,6 @@ import javax.servlet.ServletContextListener;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
/** /**
* This class is capable of receiving notifications about the undeployment of * This class is capable of receiving notifications about the undeployment of
* a webapp, and responds by ensuring that commons-logging releases all * a webapp, and responds by ensuring that commons-logging releases all

View File

@@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.logging.impl; package org.apache.commons.logging.impl;
import java.io.InputStream; import java.io.InputStream;
@@ -75,29 +74,29 @@ import org.apache.commons.logging.LogConfigurationException;
*/ */
public class SimpleLog implements Log, Serializable { public class SimpleLog implements Log, Serializable {
// ------------------------------------------------------- Class Attributes // ------------------------------------------------------- Class Attributes
/** All system properties used by <code>SimpleLog</code> start with this */ /** All system properties used by <code>SimpleLog</code> start with this */
static protected final String systemPrefix = static protected final String systemPrefix = "org.apache.commons.logging.simplelog.";
"org.apache.commons.logging.simplelog.";
/** Properties loaded from simplelog.properties */ /** Properties loaded from simplelog.properties */
static protected final Properties simpleLogProps = new Properties(); static protected final Properties simpleLogProps = new Properties();
/** The default format to use when formating dates */ /** The default format to use when formating dates */
static protected final String DEFAULT_DATE_TIME_FORMAT = static protected final String DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss:SSS zzz";
"yyyy/MM/dd HH:mm:ss:SSS zzz";
/** Include the instance name in the log message? */ /** Include the instance name in the log message? */
static protected boolean showLogName = false; static protected boolean showLogName = false;
/** Include the short name ( last component ) of the logger in the log /** Include the short name ( last component ) of the logger in the log
* message. Defaults to true - otherwise we'll be lost in a flood of * message. Defaults to true - otherwise we'll be lost in a flood of
* messages without knowing who sends them. * messages without knowing who sends them.
*/ */
static protected boolean showShortName = true; static protected boolean showShortName = true;
/** Include the current time in the log message */ /** Include the current time in the log message */
static protected boolean showDateTime = false; static protected boolean showDateTime = false;
/** The date and time format to use in the log message */ /** The date and time format to use in the log message */
static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT; static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
@@ -113,7 +112,6 @@ public class SimpleLog implements Log, Serializable {
// ---------------------------------------------------- Log Level Constants // ---------------------------------------------------- Log Level Constants
/** "Trace" level logging. */ /** "Trace" level logging. */
public static final int LOG_LEVEL_TRACE = 1; public static final int LOG_LEVEL_TRACE = 1;
/** "Debug" level logging. */ /** "Debug" level logging. */
@@ -196,7 +194,6 @@ public class SimpleLog implements Log, Serializable {
/** The short name of this simple log instance */ /** The short name of this simple log instance */
private String shortLogName = null; private String shortLogName = null;
// ------------------------------------------------------------ Constructor // ------------------------------------------------------------ Constructor
/** /**
@@ -246,7 +243,6 @@ public class SimpleLog implements Log, Serializable {
} }
// -------------------------------------------------------- Properties // -------------------------------------------------------- Properties
/** /**
@@ -260,23 +256,20 @@ public class SimpleLog implements Log, Serializable {
} }
/** /**
* <p> Get logging level. </p> * Get logging level.
*/ */
public int getLevel() { public int getLevel() {
return currentLogLevel; return currentLogLevel;
} }
// -------------------------------------------------------- Logging Methods // -------------------------------------------------------- Logging Methods
/** /**
* <p> Do the actual logging. * Do the actual logging.
* This method assembles the message * <p>
* and then calls <code>write()</code> to cause it to be written.</p> * This method assembles the message and then calls <code>write()</code>
* to cause it to be written.
* *
* @param type One of the LOG_LEVEL_XXX constants defining the log level * @param type One of the LOG_LEVEL_XXX constants defining the log level
* @param message The message itself (typically a String) * @param message The message itself (typically a String)
@@ -337,10 +330,8 @@ public class SimpleLog implements Log, Serializable {
// Print to the appropriate destination // Print to the appropriate destination
write(buf); write(buf);
} }
/** /**
* <p>Write the content of the message accumulated in the specified * <p>Write the content of the message accumulated in the specified
* <code>StringBuffer</code> to the appropriate output destination. The * <code>StringBuffer</code> to the appropriate output destination. The
@@ -350,12 +341,9 @@ public class SimpleLog implements Log, Serializable {
* text to be logged * text to be logged
*/ */
protected void write(StringBuffer buffer) { protected void write(StringBuffer buffer) {
System.err.println(buffer.toString()); System.err.println(buffer.toString());
} }
/** /**
* Is the given log level currently enabled? * Is the given log level currently enabled?
* *
@@ -367,10 +355,8 @@ public class SimpleLog implements Log, Serializable {
return logLevel >= currentLogLevel; return logLevel >= currentLogLevel;
} }
// -------------------------------------------------------- Log Implementation // -------------------------------------------------------- Log Implementation
/** /**
* Logs a message with * Logs a message with
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>. * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
@@ -379,13 +365,11 @@ public class SimpleLog implements Log, Serializable {
* @see org.apache.commons.logging.Log#debug(Object) * @see org.apache.commons.logging.Log#debug(Object)
*/ */
public final void debug(Object message) { public final void debug(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
log(SimpleLog.LOG_LEVEL_DEBUG, message, null); log(SimpleLog.LOG_LEVEL_DEBUG, message, null);
} }
} }
/** /**
* Logs a message with * Logs a message with
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>. * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
@@ -395,246 +379,202 @@ public class SimpleLog implements Log, Serializable {
* @see org.apache.commons.logging.Log#debug(Object, Throwable) * @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/ */
public final void debug(Object message, Throwable t) { public final void debug(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
log(SimpleLog.LOG_LEVEL_DEBUG, message, t); log(SimpleLog.LOG_LEVEL_DEBUG, message, t);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#trace(Object) * @see org.apache.commons.logging.Log#trace(Object)
*/ */
public final void trace(Object message) { public final void trace(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
log(SimpleLog.LOG_LEVEL_TRACE, message, null); log(SimpleLog.LOG_LEVEL_TRACE, message, null);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable) * @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/ */
public final void trace(Object message, Throwable t) { public final void trace(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
log(SimpleLog.LOG_LEVEL_TRACE, message, t); log(SimpleLog.LOG_LEVEL_TRACE, message, t);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#info(Object) * @see org.apache.commons.logging.Log#info(Object)
*/ */
public final void info(Object message) { public final void info(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
log(SimpleLog.LOG_LEVEL_INFO,message,null); log(SimpleLog.LOG_LEVEL_INFO,message,null);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable) * @see org.apache.commons.logging.Log#info(Object, Throwable)
*/ */
public final void info(Object message, Throwable t) { public final void info(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
log(SimpleLog.LOG_LEVEL_INFO, message, t); log(SimpleLog.LOG_LEVEL_INFO, message, t);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#warn(Object) * @see org.apache.commons.logging.Log#warn(Object)
*/ */
public final void warn(Object message) { public final void warn(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
log(SimpleLog.LOG_LEVEL_WARN, message, null); log(SimpleLog.LOG_LEVEL_WARN, message, null);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable) * @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/ */
public final void warn(Object message, Throwable t) { public final void warn(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
log(SimpleLog.LOG_LEVEL_WARN, message, t); log(SimpleLog.LOG_LEVEL_WARN, message, t);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#error(Object) * @see org.apache.commons.logging.Log#error(Object)
*/ */
public final void error(Object message) { public final void error(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
log(SimpleLog.LOG_LEVEL_ERROR, message, null); log(SimpleLog.LOG_LEVEL_ERROR, message, null);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable) * @see org.apache.commons.logging.Log#error(Object, Throwable)
*/ */
public final void error(Object message, Throwable t) { public final void error(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
log(SimpleLog.LOG_LEVEL_ERROR, message, t); log(SimpleLog.LOG_LEVEL_ERROR, message, t);
} }
} }
/** /**
* Log a message with * Log a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
* *
* @param message to log * @param message to log
* @see org.apache.commons.logging.Log#fatal(Object) * @see org.apache.commons.logging.Log#fatal(Object)
*/ */
public final void fatal(Object message) { public final void fatal(Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
log(SimpleLog.LOG_LEVEL_FATAL, message, null); log(SimpleLog.LOG_LEVEL_FATAL, message, null);
} }
} }
/** /**
* Logs a message with * Logs a message with <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
* <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
* *
* @param message to log * @param message to log
* @param t log this cause * @param t log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable) * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/ */
public final void fatal(Object message, Throwable t) { public final void fatal(Object message, Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
log(SimpleLog.LOG_LEVEL_FATAL, message, t); log(SimpleLog.LOG_LEVEL_FATAL, message, t);
} }
} }
/** /**
* <p> Are debug messages currently enabled? </p> * Are debug messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isDebugEnabled() { public final boolean isDebugEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG); return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG);
} }
/** /**
* <p> Are error messages currently enabled? </p> * Are error messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isErrorEnabled() { public final boolean isErrorEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR); return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR);
} }
/** /**
* <p> Are fatal messages currently enabled? </p> * Are fatal messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isFatalEnabled() { public final boolean isFatalEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL); return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL);
} }
/** /**
* <p> Are info messages currently enabled? </p> * Are info messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isInfoEnabled() { public final boolean isInfoEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO); return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO);
} }
/** /**
* <p> Are trace messages currently enabled? </p> * Are trace messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isTraceEnabled() { public final boolean isTraceEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE); return isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE);
} }
/** /**
* <p> Are warn messages currently enabled? </p> * Are warn messages currently enabled?
* * <p>
* <p> This allows expensive operations such as <code>String</code> * This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the * concatenation to be avoided when the message will be ignored by the
* logger. </p> * logger.
*/ */
public final boolean isWarnEnabled() { public final boolean isWarnEnabled() {
return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN); return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN);
} }
/** /**
* Return the thread context class loader if available. * Return the thread context class loader if available.
* Otherwise return null. * Otherwise return null.
@@ -645,8 +585,7 @@ public class SimpleLog implements Log, Serializable {
* @exception LogConfigurationException if a suitable class loader * @exception LogConfigurationException if a suitable class loader
* cannot be identified. * cannot be identified.
*/ */
private static ClassLoader getContextClassLoader() private static ClassLoader getContextClassLoader() {
{
ClassLoader classLoader = null; ClassLoader classLoader = null;
try { try {
@@ -699,8 +638,7 @@ public class SimpleLog implements Log, Serializable {
return classLoader; return classLoader;
} }
private static InputStream getResourceAsStream(final String name) private static InputStream getResourceAsStream(final String name) {
{
return (InputStream)AccessController.doPrivileged( return (InputStream)AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction() {
public Object run() { public Object run() {