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:
@@ -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 $
|
* $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.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2003/08/16 18:21:50 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
package org.apache.commons.logging.impl;
|
package org.apache.commons.logging.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import org.apache.avalon.framework.logger.Logger;
|
import org.apache.avalon.framework.logger.Logger;
|
||||||
import org.apache.commons.logging.Log;
|
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.
|
* logging calls to Avalon logging abstraction: the Logger interface.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
|
* @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 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
|
* @param logger the avalon logger implementation to delegate to
|
||||||
*/
|
*/
|
||||||
public AvalonLogger(Logger logger) {
|
public AvalonLogger(Logger logger) {
|
||||||
|
this.name = name;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +92,16 @@ public class AvalonLogger implements Log {
|
|||||||
public AvalonLogger(String name) {
|
public AvalonLogger(String name) {
|
||||||
if (defaultLogger == null)
|
if (defaultLogger == null)
|
||||||
throw new NullPointerException("default logger has to be specified if this constructor is used!");
|
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
|
* @return avalon logger implementation
|
||||||
*/
|
*/
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
|
if (logger == null) {
|
||||||
|
logger = defaultLogger.getChildLogger(name);
|
||||||
|
}
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,126 +116,126 @@ public class AvalonLogger implements Log {
|
|||||||
* @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
|
* @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void debug(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#debug(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void debug(Object o) {
|
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)
|
* @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void error(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#error(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void error(Object o) {
|
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)
|
* @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void fatal(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#fatal(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void fatal(Object o) {
|
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)
|
* @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void info(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#info(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void info(Object o) {
|
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()
|
* @see org.apache.commons.logging.Log#isDebugEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return this.logger.isDebugEnabled();
|
return getLogger().isDebugEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#isErrorEnabled()
|
* @see org.apache.commons.logging.Log#isErrorEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isErrorEnabled() {
|
public boolean isErrorEnabled() {
|
||||||
return this.logger.isErrorEnabled();
|
return getLogger().isErrorEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#isFatalEnabled()
|
* @see org.apache.commons.logging.Log#isFatalEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isFatalEnabled() {
|
public boolean isFatalEnabled() {
|
||||||
return this.logger.isFatalErrorEnabled();
|
return getLogger().isFatalErrorEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#isInfoEnabled()
|
* @see org.apache.commons.logging.Log#isInfoEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isInfoEnabled() {
|
public boolean isInfoEnabled() {
|
||||||
return this.logger.isInfoEnabled();
|
return getLogger().isInfoEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#isTraceEnabled()
|
* @see org.apache.commons.logging.Log#isTraceEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isTraceEnabled() {
|
public boolean isTraceEnabled() {
|
||||||
return this.logger.isDebugEnabled();
|
return getLogger().isDebugEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#isWarnEnabled()
|
* @see org.apache.commons.logging.Log#isWarnEnabled()
|
||||||
*/
|
*/
|
||||||
public boolean isWarnEnabled() {
|
public boolean isWarnEnabled() {
|
||||||
return this.logger.isWarnEnabled();
|
return getLogger().isWarnEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
|
* @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void trace(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#trace(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void trace(Object o) {
|
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)
|
* @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
public void warn(Object o, Throwable t) {
|
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)
|
* @see org.apache.commons.logging.Log#warn(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void warn(Object o) {
|
public void warn(Object o) {
|
||||||
if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o));
|
if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 $
|
* $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.6 $
|
* $Revision: 1.7 $
|
||||||
* $Date: 2003/03/31 00:27:08 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
package org.apache.commons.logging.impl;
|
package org.apache.commons.logging.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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: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>
|
||||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</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
|
// ----------------------------------------------------------- Constructors
|
||||||
@@ -93,7 +94,8 @@ public final class Jdk14Logger implements Log {
|
|||||||
*/
|
*/
|
||||||
public Jdk14Logger(String name) {
|
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.
|
* 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
|
// --------------------------------------------------------- Public Methods
|
||||||
|
|
||||||
private void log( Level level, String msg, Throwable ex ) {
|
private void log( Level level, String msg, Throwable ex ) {
|
||||||
|
|
||||||
|
Logger logger = getLogger();
|
||||||
if (logger.isLoggable(level)) {
|
if (logger.isLoggable(level)) {
|
||||||
// Hack (?) to get the stack trace.
|
// Hack (?) to get the stack trace.
|
||||||
Throwable dummyException=new Throwable();
|
Throwable dummyException=new Throwable();
|
||||||
@@ -128,6 +138,7 @@ public final class Jdk14Logger implements Log {
|
|||||||
logger.logp( level, cname, method, msg, ex );
|
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.
|
* Return the native Logger instance we are using.
|
||||||
*/
|
*/
|
||||||
public Logger getLogger() {
|
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?
|
* Is debug logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isDebugEnabled() {
|
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?
|
* Is error logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isErrorEnabled() {
|
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?
|
* Is fatal logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isFatalEnabled() {
|
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?
|
* Is info logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isInfoEnabled() {
|
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?
|
* Is tace logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isTraceEnabled() {
|
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?
|
* Is warning logging currently enabled?
|
||||||
*/
|
*/
|
||||||
public boolean isWarnEnabled() {
|
public boolean isWarnEnabled() {
|
||||||
return (logger.isLoggable(Level.WARNING));
|
return (getLogger().isLoggable(Level.WARNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 $
|
* $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.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2003/07/18 14:14:16 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
|
|
||||||
package org.apache.commons.logging.impl;
|
package org.apache.commons.logging.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.Priority;
|
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 <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @author Robert Burrell Donkin
|
* @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
|
// ------------------------------------------------------------- Attributes
|
||||||
@@ -86,7 +87,10 @@ public final class Log4JLogger implements Log {
|
|||||||
private static final String FQCN = Log4JLogger.class.getName();
|
private static final String FQCN = Log4JLogger.class.getName();
|
||||||
|
|
||||||
/** Log to this logger */
|
/** Log to this logger */
|
||||||
private Logger logger = null;
|
private transient Logger logger = null;
|
||||||
|
|
||||||
|
/** Logger name */
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
// ------------------------------------------------------------ Constructor
|
||||||
@@ -99,17 +103,19 @@ public final class Log4JLogger implements Log {
|
|||||||
* Base constructor
|
* Base constructor
|
||||||
*/
|
*/
|
||||||
public Log4JLogger(String name) {
|
public Log4JLogger(String name) {
|
||||||
this.logger=Logger.getLogger(name);
|
this.name = name;
|
||||||
|
this.logger = getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use with a log4j factory
|
/** For use with a log4j factory
|
||||||
*/
|
*/
|
||||||
public Log4JLogger(Logger logger ) {
|
public Log4JLogger(Logger logger ) {
|
||||||
|
this.name = logger.getName();
|
||||||
this.logger=logger;
|
this.logger=logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------- Implmentation
|
// --------------------------------------------------------- Implementation
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +123,7 @@ public final class Log4JLogger implements Log {
|
|||||||
* Currently logs to <code>DEBUG</code> level in Log4J.
|
* Currently logs to <code>DEBUG</code> level in Log4J.
|
||||||
*/
|
*/
|
||||||
public void trace(Object message) {
|
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.
|
* Currently logs to <code>DEBUG</code> level in Log4J.
|
||||||
*/
|
*/
|
||||||
public void trace(Object message, Throwable t) {
|
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.
|
* Log a message to the Log4j Logger with <code>DEBUG</code> priority.
|
||||||
*/
|
*/
|
||||||
public void debug(Object message) {
|
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.
|
* Log an error to the Log4j Logger with <code>DEBUG</code> priority.
|
||||||
*/
|
*/
|
||||||
public void debug(Object message, Throwable t) {
|
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.
|
* Log a message to the Log4j Logger with <code>INFO</code> priority.
|
||||||
*/
|
*/
|
||||||
public void info(Object message) {
|
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.
|
* Log an error to the Log4j Logger with <code>INFO</code> priority.
|
||||||
*/
|
*/
|
||||||
public void info(Object message, Throwable t) {
|
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.
|
* Log a message to the Log4j Logger with <code>WARN</code> priority.
|
||||||
*/
|
*/
|
||||||
public void warn(Object message) {
|
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.
|
* Log an error to the Log4j Logger with <code>WARN</code> priority.
|
||||||
*/
|
*/
|
||||||
public void warn(Object message, Throwable t) {
|
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.
|
* Log a message to the Log4j Logger with <code>ERROR</code> priority.
|
||||||
*/
|
*/
|
||||||
public void error(Object message) {
|
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.
|
* Log an error to the Log4j Logger with <code>ERROR</code> priority.
|
||||||
*/
|
*/
|
||||||
public void error(Object message, Throwable t) {
|
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.
|
* Log a message to the Log4j Logger with <code>FATAL</code> priority.
|
||||||
*/
|
*/
|
||||||
public void fatal(Object message) {
|
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.
|
* Log an error to the Log4j Logger with <code>FATAL</code> priority.
|
||||||
*/
|
*/
|
||||||
public void fatal(Object message, Throwable t) {
|
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.
|
* Return the native Logger instance we are using.
|
||||||
*/
|
*/
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
|
if (logger == null) {
|
||||||
|
logger = Logger.getLogger(name);
|
||||||
|
}
|
||||||
return (this.logger);
|
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.
|
* Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority.
|
||||||
*/
|
*/
|
||||||
public boolean isDebugEnabled() {
|
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.
|
* Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority.
|
||||||
*/
|
*/
|
||||||
public boolean isErrorEnabled() {
|
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.
|
* Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority.
|
||||||
*/
|
*/
|
||||||
public boolean isFatalEnabled() {
|
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.
|
* Check whether the Log4j Logger used is enabled for <code>INFO</code> priority.
|
||||||
*/
|
*/
|
||||||
public boolean isInfoEnabled() {
|
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>
|
* For Log4J, this returns the value of <code>isDebugEnabled()</code>
|
||||||
*/
|
*/
|
||||||
public boolean isTraceEnabled() {
|
public boolean isTraceEnabled() {
|
||||||
return logger.isDebugEnabled();
|
return getLogger().isDebugEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the Log4j Logger used is enabled for <code>WARN</code> priority.
|
* Check whether the Log4j Logger used is enabled for <code>WARN</code> priority.
|
||||||
*/
|
*/
|
||||||
public boolean isWarnEnabled() {
|
public boolean isWarnEnabled() {
|
||||||
return logger.isEnabledFor(Priority.WARN);
|
return getLogger().isEnabledFor(Priority.WARN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 $
|
* $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.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2003/03/30 23:42:36 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
|
|
||||||
package org.apache.commons.logging.impl;
|
package org.apache.commons.logging.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import org.apache.log.Logger;
|
import org.apache.log.Logger;
|
||||||
import org.apache.log.Hierarchy;
|
import org.apache.log.Hierarchy;
|
||||||
import org.apache.commons.logging.Log;
|
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 <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||||
* @author Robert Burrell Donkin *
|
* @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
|
// ------------------------------------------------------------- Attributes
|
||||||
|
|
||||||
|
|
||||||
/** Logging goes to this <code>LogKit</code> logger */
|
/** 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
|
// ------------------------------------------------------------ Constructor
|
||||||
@@ -101,8 +105,25 @@ public final class LogKitLogger implements Log {
|
|||||||
* @param name log name
|
* @param name log name
|
||||||
*/
|
*/
|
||||||
public LogKitLogger(String name) {
|
public LogKitLogger(String 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);
|
logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
|
||||||
}
|
}
|
||||||
|
return (logger);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- Log Implementation
|
// ----------------------------------------------------- Log Implementation
|
||||||
@@ -129,7 +150,7 @@ public final class LogKitLogger implements Log {
|
|||||||
*/
|
*/
|
||||||
public void debug(Object message) {
|
public void debug(Object message) {
|
||||||
if (message != null) {
|
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) {
|
public void debug(Object message, Throwable t) {
|
||||||
if (message != null) {
|
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) {
|
public void info(Object message) {
|
||||||
if (message != null) {
|
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) {
|
public void info(Object message, Throwable t) {
|
||||||
if (message != null) {
|
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) {
|
public void warn(Object message) {
|
||||||
if (message != null) {
|
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) {
|
public void warn(Object message, Throwable t) {
|
||||||
if (message != null) {
|
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) {
|
public void error(Object message) {
|
||||||
if (message != null) {
|
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) {
|
public void error(Object message, Throwable t) {
|
||||||
if (message != null) {
|
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) {
|
public void fatal(Object message) {
|
||||||
if (message != null) {
|
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) {
|
public void fatal(Object message, Throwable t) {
|
||||||
if (message != null) {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isDebugEnabled() {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>ERROR</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isErrorEnabled() {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>FATAL_ERROR</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isFatalEnabled() {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>INFO</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isInfoEnabled() {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isTraceEnabled() {
|
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>.
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>WARN</code>.
|
||||||
*/
|
*/
|
||||||
public boolean isWarnEnabled() {
|
public boolean isWarnEnabled() {
|
||||||
return logger.isWarnEnabled();
|
return getLogger().isWarnEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 $
|
* $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.5 $
|
* $Revision: 1.6 $
|
||||||
* $Date: 2003/07/18 14:11:45 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -80,7 +80,7 @@ import junit.framework.TestSuite;
|
|||||||
* logger configured per the configuration properties.</p>
|
* logger configured per the configuration properties.</p>
|
||||||
*
|
*
|
||||||
* @author Craig R. McClanahan
|
* @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 {
|
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
|
// Test pristine Logger instance
|
||||||
public void testPristineLogger() {
|
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
|
// -------------------------------------------------------- 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
|
// Check the recorded messages
|
||||||
protected void checkLogRecords(boolean thrown) {
|
protected void checkLogRecords(boolean thrown) {
|
||||||
Iterator records = handler.records();
|
Iterator records = handler.records();
|
||||||
|
|||||||
@@ -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 $
|
* $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.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2003/07/18 14:11:45 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -62,6 +62,11 @@
|
|||||||
package org.apache.commons.logging.jdk14;
|
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.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* should be automatically configured.</p>
|
* should be automatically configured.</p>
|
||||||
*
|
*
|
||||||
* @author Craig R. McClanahan
|
* @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 {
|
public class DefaultConfigTestCase extends TestCase {
|
||||||
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
|
|||||||
// Test pristine Log instance
|
// Test pristine Log instance
|
||||||
public void testPristineLog() {
|
public void testPristineLog() {
|
||||||
|
|
||||||
assertNotNull("Log exists", log);
|
checkLog();
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
// -------------------------------------------------------- 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
|
// Set up factory instance
|
||||||
protected void setUpFactory() throws Exception {
|
protected void setUpFactory() throws Exception {
|
||||||
factory = LogFactory.getFactory();
|
factory = LogFactory.getFactory();
|
||||||
|
|||||||
@@ -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 $
|
* $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.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2003/07/18 14:11:45 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -82,7 +82,7 @@ import org.apache.log4j.spi.LoggingEvent;
|
|||||||
* logger configured per the configuration properties.</p>
|
* logger configured per the configuration properties.</p>
|
||||||
*
|
*
|
||||||
* @author Craig R. McClanahan
|
* @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 {
|
public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||||
@@ -197,13 +197,6 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
|
|
||||||
super.testPristineLog();
|
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
|
// -------------------------------------------------------- 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
|
// Check the recorded messages
|
||||||
protected void checkLoggingEvents(boolean thrown) {
|
protected void checkLoggingEvents(boolean thrown) {
|
||||||
Iterator events = appender.events();
|
Iterator events = appender.events();
|
||||||
|
|||||||
@@ -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 $
|
* $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.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2003/07/18 14:11:45 $
|
* $Date: 2003/08/16 21:58:59 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -62,6 +62,11 @@
|
|||||||
package org.apache.commons.logging.log4j;
|
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.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* should be automatically configured).</p>
|
* should be automatically configured).</p>
|
||||||
*
|
*
|
||||||
* @author Craig R. McClanahan
|
* @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 {
|
public class DefaultConfigTestCase extends TestCase {
|
||||||
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
|
|||||||
// Test pristine Log instance
|
// Test pristine Log instance
|
||||||
public void testPristineLog() {
|
public void testPristineLog() {
|
||||||
|
|
||||||
assertNotNull("Log exists", log);
|
checkLog();
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
// -------------------------------------------------------- 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
|
// Set up factory instance
|
||||||
protected void setUpFactory() throws Exception {
|
protected void setUpFactory() throws Exception {
|
||||||
factory = LogFactory.getFactory();
|
factory = LogFactory.getFactory();
|
||||||
|
|||||||
Reference in New Issue
Block a user