1
0

Make the remaining non-deprecated Log implementations also implement

Serializable, and enhance the unit tests for JDK 1.4 an Log4J logging
to validate the ability to deserialize and use such instances.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Craig R. McClanahan
2003-08-16 21:58:59 +00:00
parent 45c7fb43cb
commit e7c2d81417
8 changed files with 299 additions and 151 deletions

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java,v 1.3 2003/08/16 18:21:50 craigmcc Exp $
* $Revision: 1.3 $
* $Date: 2003/08/16 18:21:50 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java,v 1.4 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.4 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -61,6 +61,7 @@
package org.apache.commons.logging.impl;
import java.io.Serializable;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
@@ -69,17 +70,19 @@ import org.apache.commons.logging.Log;
* logging calls to Avalon logging abstraction: the Logger interface.
*
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Revision: 1.3 $ $Date: 2003/08/16 18:21:50 $
* @version $Revision: 1.4 $ $Date: 2003/08/16 21:58:59 $
*/
public class AvalonLogger implements Log {
public class AvalonLogger implements Log, Serializable {
private static Logger defaultLogger = null;
private Logger logger = null;
private transient Logger logger = null;
private String name = null;
/**
* @param logger the avalon logger implementation to delegate to
*/
public AvalonLogger(Logger logger) {
this.name = name;
this.logger = logger;
}
@@ -89,13 +92,16 @@ public class AvalonLogger implements Log {
public AvalonLogger(String name) {
if (defaultLogger == null)
throw new NullPointerException("default logger has to be specified if this constructor is used!");
this.logger = defaultLogger.getChildLogger(name);
this.logger = getLogger();
}
/**
* @return avalon logger implementation
*/
public Logger getLogger() {
if (logger == null) {
logger = defaultLogger.getChildLogger(name);
}
return logger;
}
@@ -110,126 +116,126 @@ public class AvalonLogger implements Log {
* @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
*/
public void debug(Object o, Throwable t) {
if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#debug(java.lang.Object)
*/
public void debug(Object o) {
if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
*/
public void error(Object o, Throwable t) {
if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o), t);
if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#error(java.lang.Object)
*/
public void error(Object o) {
if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o));
if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
*/
public void fatal(Object o, Throwable t) {
if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(String.valueOf(o), t);
if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object)
*/
public void fatal(Object o) {
if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(String.valueOf(o));
if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
*/
public void info(Object o, Throwable t) {
if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o), t);
if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#info(java.lang.Object)
*/
public void info(Object o) {
if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o));
if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#isDebugEnabled()
*/
public boolean isDebugEnabled() {
return this.logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
/**
* @see org.apache.commons.logging.Log#isErrorEnabled()
*/
public boolean isErrorEnabled() {
return this.logger.isErrorEnabled();
return getLogger().isErrorEnabled();
}
/**
* @see org.apache.commons.logging.Log#isFatalEnabled()
*/
public boolean isFatalEnabled() {
return this.logger.isFatalErrorEnabled();
return getLogger().isFatalErrorEnabled();
}
/**
* @see org.apache.commons.logging.Log#isInfoEnabled()
*/
public boolean isInfoEnabled() {
return this.logger.isInfoEnabled();
return getLogger().isInfoEnabled();
}
/**
* @see org.apache.commons.logging.Log#isTraceEnabled()
*/
public boolean isTraceEnabled() {
return this.logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
/**
* @see org.apache.commons.logging.Log#isWarnEnabled()
*/
public boolean isWarnEnabled() {
return this.logger.isWarnEnabled();
return getLogger().isWarnEnabled();
}
/**
* @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
*/
public void trace(Object o, Throwable t) {
if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#trace(java.lang.Object)
*/
public void trace(Object o) {
if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
*/
public void warn(Object o, Throwable t) {
if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o), t);
if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#warn(java.lang.Object)
*/
public void warn(Object o) {
if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o));
if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(o));
}
}

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java,v 1.6 2003/03/31 00:27:08 craigmcc Exp $
* $Revision: 1.6 $
* $Date: 2003/03/31 00:27:08 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java,v 1.7 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.7 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -63,6 +63,7 @@
package org.apache.commons.logging.impl;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -77,10 +78,10 @@ import org.apache.commons.logging.Log;
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @version $Revision: 1.6 $ $Date: 2003/03/31 00:27:08 $
* @version $Revision: 1.7 $ $Date: 2003/08/16 21:58:59 $
*/
public final class Jdk14Logger implements Log {
public final class Jdk14Logger implements Log, Serializable {
// ----------------------------------------------------------- Constructors
@@ -93,7 +94,8 @@ public final class Jdk14Logger implements Log {
*/
public Jdk14Logger(String name) {
logger = Logger.getLogger(name);
this.name = name;
logger = getLogger();
}
@@ -104,12 +106,20 @@ public final class Jdk14Logger implements Log {
/**
* The underlying Logger implementation we are using.
*/
protected Logger logger = null;
protected transient Logger logger = null;
/**
* The name of the logger we are wrapping.
*/
protected String name = null;
// --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) {
Logger logger = getLogger();
if (logger.isLoggable(level)) {
// Hack (?) to get the stack trace.
Throwable dummyException=new Throwable();
@@ -128,6 +138,7 @@ public final class Jdk14Logger implements Log {
logger.logp( level, cname, method, msg, ex );
}
}
}
/**
@@ -182,7 +193,10 @@ public final class Jdk14Logger implements Log {
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
return (this.logger);
if (logger == null) {
logger = Logger.getLogger(name);
}
return (logger);
}
@@ -206,7 +220,7 @@ public final class Jdk14Logger implements Log {
* Is debug logging currently enabled?
*/
public boolean isDebugEnabled() {
return (logger.isLoggable(Level.FINE));
return (getLogger().isLoggable(Level.FINE));
}
@@ -214,7 +228,7 @@ public final class Jdk14Logger implements Log {
* Is error logging currently enabled?
*/
public boolean isErrorEnabled() {
return (logger.isLoggable(Level.SEVERE));
return (getLogger().isLoggable(Level.SEVERE));
}
@@ -222,7 +236,7 @@ public final class Jdk14Logger implements Log {
* Is fatal logging currently enabled?
*/
public boolean isFatalEnabled() {
return (logger.isLoggable(Level.SEVERE));
return (getLogger().isLoggable(Level.SEVERE));
}
@@ -230,7 +244,7 @@ public final class Jdk14Logger implements Log {
* Is info logging currently enabled?
*/
public boolean isInfoEnabled() {
return (logger.isLoggable(Level.INFO));
return (getLogger().isLoggable(Level.INFO));
}
@@ -238,7 +252,7 @@ public final class Jdk14Logger implements Log {
* Is tace logging currently enabled?
*/
public boolean isTraceEnabled() {
return (logger.isLoggable(Level.FINEST));
return (getLogger().isLoggable(Level.FINEST));
}
@@ -246,7 +260,7 @@ public final class Jdk14Logger implements Log {
* Is warning logging currently enabled?
*/
public boolean isWarnEnabled() {
return (logger.isLoggable(Level.WARNING));
return (getLogger().isLoggable(Level.WARNING));
}

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java,v 1.4 2003/07/18 14:14:16 rsitze Exp $
* $Revision: 1.4 $
* $Date: 2003/07/18 14:14:16 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.5 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -62,6 +62,7 @@
package org.apache.commons.logging.impl;
import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
@@ -75,9 +76,9 @@ import org.apache.log4j.Priority;
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
* @author Robert Burrell Donkin
* @version $Id: Log4JLogger.java,v 1.4 2003/07/18 14:14:16 rsitze Exp $
* @version $Id: Log4JLogger.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
*/
public final class Log4JLogger implements Log {
public final class Log4JLogger implements Log, Serializable {
// ------------------------------------------------------------- Attributes
@@ -86,7 +87,10 @@ public final class Log4JLogger implements Log {
private static final String FQCN = Log4JLogger.class.getName();
/** Log to this logger */
private Logger logger = null;
private transient Logger logger = null;
/** Logger name */
private String name = null;
// ------------------------------------------------------------ Constructor
@@ -99,17 +103,19 @@ public final class Log4JLogger implements Log {
* Base constructor
*/
public Log4JLogger(String name) {
this.logger=Logger.getLogger(name);
this.name = name;
this.logger = getLogger();
}
/** For use with a log4j factory
*/
public Log4JLogger(Logger logger ) {
this.name = logger.getName();
this.logger=logger;
}
// ---------------------------------------------------------- Implmentation
// --------------------------------------------------------- Implementation
/**
@@ -117,7 +123,7 @@ public final class Log4JLogger implements Log {
* Currently logs to <code>DEBUG</code> level in Log4J.
*/
public void trace(Object message) {
logger.log(FQCN, Priority.DEBUG, message, null);
getLogger().log(FQCN, Priority.DEBUG, message, null);
}
@@ -126,7 +132,7 @@ public final class Log4JLogger implements Log {
* Currently logs to <code>DEBUG</code> level in Log4J.
*/
public void trace(Object message, Throwable t) {
logger.log(FQCN, Priority.DEBUG, message, t );
getLogger().log(FQCN, Priority.DEBUG, message, t );
}
@@ -134,14 +140,14 @@ public final class Log4JLogger implements Log {
* Log a message to the Log4j Logger with <code>DEBUG</code> priority.
*/
public void debug(Object message) {
logger.log(FQCN, Priority.DEBUG, message, null);
getLogger().log(FQCN, Priority.DEBUG, message, null);
}
/**
* Log an error to the Log4j Logger with <code>DEBUG</code> priority.
*/
public void debug(Object message, Throwable t) {
logger.log(FQCN, Priority.DEBUG, message, t );
getLogger().log(FQCN, Priority.DEBUG, message, t );
}
@@ -149,7 +155,7 @@ public final class Log4JLogger implements Log {
* Log a message to the Log4j Logger with <code>INFO</code> priority.
*/
public void info(Object message) {
logger.log(FQCN, Priority.INFO, message, null );
getLogger().log(FQCN, Priority.INFO, message, null );
}
@@ -157,7 +163,7 @@ public final class Log4JLogger implements Log {
* Log an error to the Log4j Logger with <code>INFO</code> priority.
*/
public void info(Object message, Throwable t) {
logger.log(FQCN, Priority.INFO, message, t );
getLogger().log(FQCN, Priority.INFO, message, t );
}
@@ -165,7 +171,7 @@ public final class Log4JLogger implements Log {
* Log a message to the Log4j Logger with <code>WARN</code> priority.
*/
public void warn(Object message) {
logger.log(FQCN, Priority.WARN, message, null );
getLogger().log(FQCN, Priority.WARN, message, null );
}
@@ -173,7 +179,7 @@ public final class Log4JLogger implements Log {
* Log an error to the Log4j Logger with <code>WARN</code> priority.
*/
public void warn(Object message, Throwable t) {
logger.log(FQCN, Priority.WARN, message, t );
getLogger().log(FQCN, Priority.WARN, message, t );
}
@@ -181,7 +187,7 @@ public final class Log4JLogger implements Log {
* Log a message to the Log4j Logger with <code>ERROR</code> priority.
*/
public void error(Object message) {
logger.log(FQCN, Priority.ERROR, message, null );
getLogger().log(FQCN, Priority.ERROR, message, null );
}
@@ -189,7 +195,7 @@ public final class Log4JLogger implements Log {
* Log an error to the Log4j Logger with <code>ERROR</code> priority.
*/
public void error(Object message, Throwable t) {
logger.log(FQCN, Priority.ERROR, message, t );
getLogger().log(FQCN, Priority.ERROR, message, t );
}
@@ -197,7 +203,7 @@ public final class Log4JLogger implements Log {
* Log a message to the Log4j Logger with <code>FATAL</code> priority.
*/
public void fatal(Object message) {
logger.log(FQCN, Priority.FATAL, message, null );
getLogger().log(FQCN, Priority.FATAL, message, null );
}
@@ -205,7 +211,7 @@ public final class Log4JLogger implements Log {
* Log an error to the Log4j Logger with <code>FATAL</code> priority.
*/
public void fatal(Object message, Throwable t) {
logger.log(FQCN, Priority.FATAL, message, t );
getLogger().log(FQCN, Priority.FATAL, message, t );
}
@@ -213,6 +219,9 @@ public final class Log4JLogger implements Log {
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
if (logger == null) {
logger = Logger.getLogger(name);
}
return (this.logger);
}
@@ -221,7 +230,7 @@ public final class Log4JLogger implements Log {
* Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority.
*/
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
@@ -229,7 +238,7 @@ public final class Log4JLogger implements Log {
* Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority.
*/
public boolean isErrorEnabled() {
return logger.isEnabledFor(Priority.ERROR);
return getLogger().isEnabledFor(Priority.ERROR);
}
@@ -237,7 +246,7 @@ public final class Log4JLogger implements Log {
* Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority.
*/
public boolean isFatalEnabled() {
return logger.isEnabledFor(Priority.FATAL);
return getLogger().isEnabledFor(Priority.FATAL);
}
@@ -245,7 +254,7 @@ public final class Log4JLogger implements Log {
* Check whether the Log4j Logger used is enabled for <code>INFO</code> priority.
*/
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
return getLogger().isInfoEnabled();
}
@@ -254,13 +263,13 @@ public final class Log4JLogger implements Log {
* For Log4J, this returns the value of <code>isDebugEnabled()</code>
*/
public boolean isTraceEnabled() {
return logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
/**
* Check whether the Log4j Logger used is enabled for <code>WARN</code> priority.
*/
public boolean isWarnEnabled() {
return logger.isEnabledFor(Priority.WARN);
return getLogger().isEnabledFor(Priority.WARN);
}
}

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/LogKitLogger.java,v 1.3 2003/03/30 23:42:36 craigmcc Exp $
* $Revision: 1.3 $
* $Date: 2003/03/30 23:42:36 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/LogKitLogger.java,v 1.4 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.4 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -62,6 +62,7 @@
package org.apache.commons.logging.impl;
import java.io.Serializable;
import org.apache.log.Logger;
import org.apache.log.Hierarchy;
import org.apache.commons.logging.Log;
@@ -78,17 +79,20 @@ import org.apache.commons.logging.Log;
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Robert Burrell Donkin *
* @version $Id: LogKitLogger.java,v 1.3 2003/03/30 23:42:36 craigmcc Exp $
* @version $Id: LogKitLogger.java,v 1.4 2003/08/16 21:58:59 craigmcc Exp $
*/
public final class LogKitLogger implements Log {
public final class LogKitLogger implements Log, Serializable {
// ------------------------------------------------------------- Attributes
/** Logging goes to this <code>LogKit</code> logger */
protected Logger logger = null;
protected transient Logger logger = null;
/** Name of this logger */
protected String name = null;
// ------------------------------------------------------------ Constructor
@@ -101,7 +105,24 @@ public final class LogKitLogger implements Log {
* @param name log name
*/
public LogKitLogger(String name) {
logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
this.name = name;
this.logger = getLogger();
}
// --------------------------------------------------------- Public Methods
/**
* <p>Return the underlying Logger we are using.</p>
*/
public Logger getLogger() {
if (logger == null) {
logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
}
return (logger);
}
@@ -129,7 +150,7 @@ public final class LogKitLogger implements Log {
*/
public void debug(Object message) {
if (message != null) {
logger.debug(String.valueOf(message));
getLogger().debug(String.valueOf(message));
}
}
@@ -139,7 +160,7 @@ public final class LogKitLogger implements Log {
*/
public void debug(Object message, Throwable t) {
if (message != null) {
logger.debug(String.valueOf(message), t);
getLogger().debug(String.valueOf(message), t);
}
}
@@ -149,7 +170,7 @@ public final class LogKitLogger implements Log {
*/
public void info(Object message) {
if (message != null) {
logger.info(String.valueOf(message));
getLogger().info(String.valueOf(message));
}
}
@@ -159,7 +180,7 @@ public final class LogKitLogger implements Log {
*/
public void info(Object message, Throwable t) {
if (message != null) {
logger.info(String.valueOf(message), t);
getLogger().info(String.valueOf(message), t);
}
}
@@ -169,7 +190,7 @@ public final class LogKitLogger implements Log {
*/
public void warn(Object message) {
if (message != null) {
logger.warn(String.valueOf(message));
getLogger().warn(String.valueOf(message));
}
}
@@ -179,7 +200,7 @@ public final class LogKitLogger implements Log {
*/
public void warn(Object message, Throwable t) {
if (message != null) {
logger.warn(String.valueOf(message), t);
getLogger().warn(String.valueOf(message), t);
}
}
@@ -189,7 +210,7 @@ public final class LogKitLogger implements Log {
*/
public void error(Object message) {
if (message != null) {
logger.error(String.valueOf(message));
getLogger().error(String.valueOf(message));
}
}
@@ -199,7 +220,7 @@ public final class LogKitLogger implements Log {
*/
public void error(Object message, Throwable t) {
if (message != null) {
logger.error(String.valueOf(message), t);
getLogger().error(String.valueOf(message), t);
}
}
@@ -209,7 +230,7 @@ public final class LogKitLogger implements Log {
*/
public void fatal(Object message) {
if (message != null) {
logger.fatalError(String.valueOf(message));
getLogger().fatalError(String.valueOf(message));
}
}
@@ -219,7 +240,7 @@ public final class LogKitLogger implements Log {
*/
public void fatal(Object message, Throwable t) {
if (message != null) {
logger.fatalError(String.valueOf(message), t);
getLogger().fatalError(String.valueOf(message), t);
}
}
@@ -228,7 +249,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
*/
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
@@ -236,7 +257,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>ERROR</code>.
*/
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
return getLogger().isErrorEnabled();
}
@@ -244,7 +265,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>FATAL_ERROR</code>.
*/
public boolean isFatalEnabled() {
return logger.isFatalErrorEnabled();
return getLogger().isFatalErrorEnabled();
}
@@ -252,7 +273,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>INFO</code>.
*/
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
return getLogger().isInfoEnabled();
}
@@ -260,7 +281,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
*/
public boolean isTraceEnabled() {
return logger.isDebugEnabled();
return getLogger().isDebugEnabled();
}
@@ -268,7 +289,7 @@ public final class LogKitLogger implements Log {
* Check whether the <code>LogKit</code> logger will log messages of priority <code>WARN</code>.
*/
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
return getLogger().isWarnEnabled();
}

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v 1.5 2003/07/18 14:11:45 rsitze Exp $
* $Revision: 1.5 $
* $Date: 2003/07/18 14:11:45 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v 1.6 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.6 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -80,7 +80,7 @@ import junit.framework.TestSuite;
* logger configured per the configuration properties.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.5 $ $Date: 2003/07/18 14:11:45 $
* @version $Revision: 1.6 $ $Date: 2003/08/16 21:58:59 $
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {
@@ -206,22 +206,6 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
}
// Test pristine Log instance
public void testPristineLog() {
super.testPristineLog();
// Assert which logging levels have been enabled
assertTrue(log.isFatalEnabled());
assertTrue(log.isErrorEnabled());
assertTrue(log.isWarnEnabled());
assertTrue(log.isInfoEnabled());
assertTrue(log.isDebugEnabled());
assertTrue(!log.isTraceEnabled());
}
// Test pristine Logger instance
public void testPristineLogger() {
@@ -240,9 +224,37 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
}
// Test Serializability of Log instance
public void testSerializable() throws Exception {
super.testSerializable();
testExceptionMessages();
}
// -------------------------------------------------------- Support Methods
// Check the log instance
protected void checkLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Jdk14Logger",
log.getClass().getName());
// Assert which logging levels have been enabled
assertTrue(log.isFatalEnabled());
assertTrue(log.isErrorEnabled());
assertTrue(log.isWarnEnabled());
assertTrue(log.isInfoEnabled());
assertTrue(log.isDebugEnabled());
assertTrue(!log.isTraceEnabled());
}
// Check the recorded messages
protected void checkLogRecords(boolean thrown) {
Iterator records = handler.records();

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v 1.4 2003/07/18 14:11:45 rsitze Exp $
* $Revision: 1.4 $
* $Date: 2003/07/18 14:11:45 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.5 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -62,6 +62,11 @@
package org.apache.commons.logging.jdk14;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
* should be automatically configured.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.4 $ $Date: 2003/07/18 14:11:45 $
* @version $Revision: 1.5 $ $Date: 2003/08/16 21:58:59 $
*/
public class DefaultConfigTestCase extends TestCase {
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
// Test pristine Log instance
public void testPristineLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Jdk14Logger",
log.getClass().getName());
// Can we call level checkers with no exceptions?
log.isDebugEnabled();
log.isErrorEnabled();
log.isFatalEnabled();
log.isInfoEnabled();
log.isTraceEnabled();
log.isWarnEnabled();
checkLog();
}
@@ -176,10 +170,49 @@ public class DefaultConfigTestCase extends TestCase {
}
// Test Serializability of Log instance
public void testSerializable() throws Exception {
// Serialize and deserialize the instance
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject();
ois.close();
// Check the characteristics of the resulting object
checkLog();
}
// -------------------------------------------------------- Support Methods
// Check the log instance
protected void checkLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Jdk14Logger",
log.getClass().getName());
// Can we call level checkers with no exceptions?
log.isDebugEnabled();
log.isErrorEnabled();
log.isFatalEnabled();
log.isInfoEnabled();
log.isTraceEnabled();
log.isWarnEnabled();
}
// Set up factory instance
protected void setUpFactory() throws Exception {
factory = LogFactory.getFactory();

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v 1.4 2003/07/18 14:11:45 rsitze Exp $
* $Revision: 1.4 $
* $Date: 2003/07/18 14:11:45 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.5 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -82,7 +82,7 @@ import org.apache.log4j.spi.LoggingEvent;
* logger configured per the configuration properties.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.4 $ $Date: 2003/07/18 14:11:45 $
* @version $Revision: 1.5 $ $Date: 2003/08/16 21:58:59 $
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {
@@ -197,13 +197,6 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
super.testPristineLog();
// Assert which logging levels have been enabled
assertTrue(log.isErrorEnabled());
assertTrue(log.isWarnEnabled());
assertTrue(log.isInfoEnabled());
assertTrue(!log.isDebugEnabled());
assertTrue(!log.isTraceEnabled());
}
@@ -217,9 +210,36 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
}
// Test Serializability of Log instance
public void testSerializable() throws Exception {
super.testSerializable();
testExceptionMessages();
}
// -------------------------------------------------------- Support Methods
// Check the log instance
protected void checkLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Log4JLogger",
log.getClass().getName());
// Assert which logging levels have been enabled
assertTrue(log.isErrorEnabled());
assertTrue(log.isWarnEnabled());
assertTrue(log.isInfoEnabled());
assertTrue(!log.isDebugEnabled());
assertTrue(!log.isTraceEnabled());
}
// Check the recorded messages
protected void checkLoggingEvents(boolean thrown) {
Iterator events = appender.events();

View File

@@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v 1.3 2003/07/18 14:11:45 rsitze Exp $
* $Revision: 1.3 $
* $Date: 2003/07/18 14:11:45 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v 1.4 2003/08/16 21:58:59 craigmcc Exp $
* $Revision: 1.4 $
* $Date: 2003/08/16 21:58:59 $
*
* ====================================================================
*
@@ -62,6 +62,11 @@
package org.apache.commons.logging.log4j;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
* should be automatically configured).</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.3 $ $Date: 2003/07/18 14:11:45 $
* @version $Revision: 1.4 $ $Date: 2003/08/16 21:58:59 $
*/
public class DefaultConfigTestCase extends TestCase {
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
// Test pristine Log instance
public void testPristineLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Log4JLogger",
log.getClass().getName());
// Can we call level checkers with no exceptions?
log.isDebugEnabled();
log.isErrorEnabled();
log.isFatalEnabled();
log.isInfoEnabled();
log.isTraceEnabled();
log.isWarnEnabled();
checkLog();
}
@@ -176,10 +170,49 @@ public class DefaultConfigTestCase extends TestCase {
}
// Test Serializability of Log instance
public void testSerializable() throws Exception {
// Serialize and deserialize the instance
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject();
ois.close();
// Check the characteristics of the resulting object
checkLog();
}
// -------------------------------------------------------- Support Methods
// Check the log instance
protected void checkLog() {
assertNotNull("Log exists", log);
assertEquals("Log class",
"org.apache.commons.logging.impl.Log4JLogger",
log.getClass().getName());
// Can we call level checkers with no exceptions?
log.isDebugEnabled();
log.isErrorEnabled();
log.isFatalEnabled();
log.isInfoEnabled();
log.isTraceEnabled();
log.isWarnEnabled();
}
// Set up factory instance
protected void setUpFactory() throws Exception {
factory = LogFactory.getFactory();