1
0

Implement the agreed-upon API changes for the commons-logging package.

If the changes are too radical, I tagged things with "before_clean_up" to make
it easy to go back.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138835 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Craig R. McClanahan
2002-01-17 01:47:49 +00:00
parent 36652638b4
commit b39b2191aa
8 changed files with 440 additions and 231 deletions

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/AbstractLog.java,v 1.1 2002/01/03 18:52:25 rdonkin Exp $
* $Revision: 1.1 $
* $Date: 2002/01/03 18:52:25 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/AbstractLog.java,v 1.2 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.2 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,27 +65,30 @@ package org.apache.commons.logging;
/**
* <p> This is an abstract implementation of the <code>Log</code> interface.
* It provides the following common services for the actual concrete implementations:
* It provides the following common services for the actual concrete
* implementations:
*
* <h4> Log Level Property </h4>
* <p> Property getter and setter for log levels. </p>
*
* <h4> Log Level Enforcement</h4>
* <p> The current log level is checked and then the message will be passed onto the
* subclass implementation if the level is currently enabled. </p>
* <p> The current log level is checked and then the message will be passed
* onto the subclass implementation if the level is currently enabled. </p>
*
* @author Robert Burrell Donkin
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
public abstract class AbstractLog implements Log {
// --------------------------------------------------------- Attributes
// ------------------------------------------------------------- Attributes
/** Default log level is currently <code>OFF</code> */
private int currentLogLevel = Log.OFF;
// --------------------------------------------------------- Properties
// ------------------------------------------------------------- Properties
/**
* <p> Set logging level. </p>
@@ -97,6 +100,7 @@ public abstract class AbstractLog implements Log {
this.currentLogLevel = currentLogLevel;
}
/**
* <p> Get logging level. </p>
*/
@@ -105,44 +109,9 @@ public abstract class AbstractLog implements Log {
return currentLogLevel;
}
/**
* <p> Are debug messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code> concatination
* to be avoided when the message will be ignored by the logger. </p>
*
* <p> This implementation checks that the log level is debug or lower.
* If it is, then it passes the request onto {@link #isDebugEnabledImpl}.
*/
public final boolean isDebugEnabled() {
if (isLevelEnabled(Log.DEBUG)) {
return isDebugEnabledImpl();
}
// -------------------------------------------------------- Logging Methods
return false;
}
/**
* <p> Are info messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code> concatination
* to be avoided when the message will be ignored by the logger. </p>
*
* <p> This implementation checks that the log level is debug or lower.
* If it is, then it passes the request onto {@link #isInfoEnabledImpl}.
*/
public final boolean isInfoEnabled() {
if (isLevelEnabled(Log.INFO)) {
return isInfoEnabledImpl();
}
return false;
}
// --------------------------------------------------------- Logging Methods
/**
* <p> Log a message with debug log level.</p>
@@ -157,6 +126,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log an error with debug log level.</p>
*
@@ -170,6 +140,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log a message with info log level.</p>
*
@@ -183,6 +154,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log an error with info log level.</p>
*
@@ -196,6 +168,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log a message with warn log level.</p>
*
@@ -209,6 +182,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log an error with warn log level.</p>
*
@@ -222,6 +196,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log a message with error log level.</p>
*
@@ -235,6 +210,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log an error with error log level.</p>
*
@@ -248,6 +224,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log a message with fatal log level.</p>
*
@@ -261,6 +238,7 @@ public abstract class AbstractLog implements Log {
}
}
/**
* <p> Log an error with fatal log level.</p>
*
@@ -275,8 +253,107 @@ public abstract class AbstractLog implements Log {
}
/**
* <p> Are debug messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the
* logger. </p>
*
* <p> This implementation checks that the log level is debug or lower.
* If it is, then it passes the request onto {@link #isDebugEnabledImpl}.
*/
public final boolean isDebugEnabled() {
// --------------------------------------------------------- Decorated Implementation
if (isLevelEnabled(Log.DEBUG)) {
return isDebugEnabledImpl();
}
return false;
}
/**
* <p> Are error messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the
* logger. </p>
*
* <p> This implementation checks that the log level is error or lower.
* If it is, then it passes the request onto {@link #isErrorEnabledImpl}.
*/
public final boolean isErrorEnabled() {
if (isLevelEnabled(Log.ERROR)) {
return isErrorEnabledImpl();
}
return false;
}
/**
* <p> Are fatal messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the
* logger. </p>
*
* <p> This implementation checks that the log level is fatal or lower.
* If it is, then it passes the request onto {@link #isFatalEnabledImpl}.
*/
public final boolean isFatalEnabled() {
if (isLevelEnabled(Log.FATAL)) {
return isFatalEnabledImpl();
}
return false;
}
/**
* <p> Are info messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the
* logger. </p>
*
* <p> This implementation checks that the log level is info or lower.
* If it is, then it passes the request onto {@link #isInfoEnabledImpl}.
*/
public final boolean isInfoEnabled() {
if (isLevelEnabled(Log.INFO)) {
return isInfoEnabledImpl();
}
return false;
}
/**
* <p> Are warn messages currently enabled? </p>
*
* <p> This allows expensive operations such as <code>String</code>
* concatenation to be avoided when the message will be ignored by the
* logger. </p>
*
* <p> This implementation checks that the log level is warn or lower.
* If it is, then it passes the request onto {@link #isWarnEnabledImpl}.
*/
public final boolean isWarnEnabled() {
if (isLevelEnabled(Log.WARN)) {
return isWarnEnabledImpl();
}
return false;
}
// ----------------------------------------------- Decorated Implementation
/**
* <p> [OVERRIDE] Log a message with debug log level.
@@ -355,6 +432,30 @@ public abstract class AbstractLog implements Log {
return true;
}
/**
* <p> Are error messages currently enabled? </p>
*
* <p> Subclasses should override this method if their logger provides
* a special implementation. </p>
*
* @return true
*/
protected boolean isErrorEnabledImpl() {
return true;
}
/**
* <p> Are fatal messages currently enabled? </p>
*
* <p> Subclasses should override this method if their logger provides
* a special implementation. </p>
*
* @return true
*/
protected boolean isFatalEnabledImpl() {
return true;
}
/**
* <p> Are info messages currently enabled? </p>
*
@@ -367,9 +468,22 @@ public abstract class AbstractLog implements Log {
return true;
}
/**
* <p> Are warn messages currently enabled? </p>
*
* <p> Subclasses should override this method if their logger provides
* a special implementation. </p>
*
* @return true
*/
protected boolean isWarnEnabledImpl() {
return true;
}
// --------------------------------------------------------- Implementation Methods
// ------------------------------------------------- Implementation Methods
/**
* Is the given log level currently enabled?
@@ -377,7 +491,10 @@ public abstract class AbstractLog implements Log {
* @param logLevel is this level enabled?
*/
protected boolean isLevelEnabled(int logLevel) {
// log level are numerically ordered so can use simple numeric comparison
// log level are numerically ordered so can use simple numeric
// comparison
return (logLevel >= currentLogLevel);
}
}

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/Attic/Jdk14Logger.java,v 1.1 2002/01/05 22:40:40 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2002/01/05 22:40:40 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Jdk14Logger.java,v 1.2 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.2 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
@@ -73,10 +73,10 @@ import java.util.logging.Logger;
* introduced in the Merlin release (JDK 1.4).</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2002/01/05 22:40:40 $
* @version $Revision: 1.2 $ $Date: 2002/01/17 01:47:49 $
*/
public class Jdk14Logger implements Log {
public final class Jdk14Logger implements Log {
// ----------------------------------------------------------- Constructors
@@ -168,35 +168,6 @@ public class Jdk14Logger implements Log {
}
/**
* Return the current logging level.
*/
public int getLevel() {
Level level = logger.getLevel();
if (level == Level.ALL) {
return (ALL);
} else if (level == Level.SEVERE) {
return (ERROR);
} else if (level == Level.WARNING) {
return (WARN);
} else if (level == Level.INFO) {
return (INFO);
} else if (level == Level.CONFIG) {
return (DEBUG);
} else if (level == Level.FINE) {
return (DEBUG);
} else if (level == Level.FINER) {
return (DEBUG);
} else if (level == Level.FINEST) {
return (DEBUG);
} else {
return (OFF);
}
}
/**
* Return the native Logger instance we are using.
*/
@@ -237,6 +208,26 @@ public class Jdk14Logger implements Log {
}
/**
* Is error logging currently enabled?
*/
public boolean isErrorEnabled() {
return (logger.isLoggable(Level.SEVERE));
}
/**
* Is fatal logging currently enabled?
*/
public boolean isFatalEnabled() {
return (logger.isLoggable(Level.SEVERE));
}
/**
* Is info logging currently enabled?
*/
@@ -248,27 +239,11 @@ public class Jdk14Logger implements Log {
/**
* Set the new logging level.
*
* @param level New logging level
* Is warning logging currently enabled?
*/
public void setLevel(int level) {
public boolean isWarnEnabled() {
if (level == OFF) {
logger.setLevel(Level.OFF);
} else if (level >= FATAL) {
logger.setLevel(Level.SEVERE);
} else if (level >= ERROR) {
logger.setLevel(Level.SEVERE);
} else if (level >= WARN) {
logger.setLevel(Level.WARNING);
} else if (level >= INFO) {
logger.setLevel(Level.INFO);
} else if (level >= DEBUG) {
logger.setLevel(Level.FINEST);
} else if (level >= ALL) {
logger.setLevel(Level.ALL);
}
return (logger.isLoggable(Level.WARNING));
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Log.java,v 1.8 2002/01/03 18:54:29 rdonkin Exp $
* $Revision: 1.8 $
* $Date: 2002/01/03 18:54:29 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Log.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.9 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,10 +63,10 @@
package org.apache.commons.logging;
/**
* <p> A simple logging interface abstracting logging APIs. In order to be
* <p>A simple logging interface abstracting logging APIs. In order to be
* instantiated successfully by {@link LogSource}, classes that implement
* this interface must have a constructor that takes a single String
* parameter representing the "name" of this Log. </p>
* parameter representing the "name" of this Log.</p>
*
* <p> The log level determines whether a particular message
* should be passed to the logging implementation.
@@ -74,15 +74,21 @@ package org.apache.commons.logging;
* For example, if the log level is <code>warn</code>
* then the message passed to {@link #error} will be passed to the logging
* implementation but if the log level is <code>fatal</code> or higher
* then the message will not.
* then the message will not.</p>
*
* <p>The logging level constants are provided for the convenience of
* {@link Log} implementations that wish to support dynamic changes in the
* logging level configuration. However, configuration will generally be done
* external to the Logging APIs, through whatever mechanism is supported by
* the underlying logging implementation in use.</p>
*
* @author Rod Waldhoff
* @version $Id: Log.java,v 1.8 2002/01/03 18:54:29 rdonkin Exp $
* @version $Id: Log.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
*/
public interface Log {
// --------------------------------------------------------- Log Level Constants
// ---------------------------------------------------- Log Level Constants
/** All logging level. */
public static final int ALL = Integer.MIN_VALUE;
@@ -100,7 +106,8 @@ public interface Log {
public static final int OFF = Integer.MAX_VALUE;
// --------------------------------------------------------- Logging Properties
// ----------------------------------------------------- Logging Properties
/**
* <p> Is debug logging currently enabled? </p>
@@ -111,37 +118,56 @@ public interface Log {
*/
public boolean isDebugEnabled();
/**
* <p> Is error logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatination)
* when the log level is more than error. </p>
*/
public boolean isErrorEnabled();
/**
* <p> Is fatal logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatination)
* when the log level is more than fatal. </p>
*/
public boolean isFatalEnabled();
/**
* <p> Is info logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatination)
* when the log level is more than debug. </p>
* when the log level is more than info. </p>
*/
public boolean isInfoEnabled();
/**
* <p> Set logging level. </p>
* <p> Is warning logging currently enabled? </p>
*
* @param level new logging level
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatination)
* when the log level is more than warning. </p>
*/
public void setLevel(int level);
/**
* <p> Get logging level. </p>
*/
public int getLevel();
public boolean isWarnEnabled();
// -------------------------------------------------------- Logging Methods
// --------------------------------------------------------- Logging Methods
/**
* <p> Log a message with debug log level </p>
*/
public void debug(Object message);
/**
* <p> Log an error with debug log level </p>
*/
@@ -153,6 +179,7 @@ public interface Log {
*/
public void info(Object message);
/**
* <p> Log an error with info log level </p>
*/
@@ -164,6 +191,7 @@ public interface Log {
*/
public void warn(Object message);
/**
* <p> Log an error with warn log level </p>
*/
@@ -175,6 +203,7 @@ public interface Log {
*/
public void error(Object message);
/**
* <p> Log an error with error log level </p>
*/
@@ -186,9 +215,11 @@ public interface Log {
*/
public void fatal(Object message);
/**
* <p> Log an error with fatal log level </p>
*/
public void fatal(Object message, Throwable t);
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Log4JCategoryLog.java,v 1.7 2002/01/03 18:59:57 rdonkin Exp $
* $Revision: 1.7 $
* $Date: 2002/01/03 18:59:57 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Log4JCategoryLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.8 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -71,120 +71,153 @@ import org.apache.log4j.Priority;
* Category instances should be done in the usual manner, as outlined in
* the Log4J documentation.</p>
*
* <p> Log level management is now independent of the Log4J configuration.
* Log4J will not be called unless the log level is currently enabled. </p>
*
* @author Rod Waldhoff
* @author Robert Burrell Donkin
*
* @version $Id: Log4JCategoryLog.java,v 1.7 2002/01/03 18:59:57 rdonkin Exp $
* @version $Id: Log4JCategoryLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
*/
public final class Log4JCategoryLog extends AbstractLog {
public final class Log4JCategoryLog implements Log {
// ------------------------------------------------------------- Attributes
// --------------------------------------------------------- Attributes
/** Log to this category */
Category _category = null;
Category category = null;
// --------------------------------------------------------- Constructor
// ------------------------------------------------------------ Constructor
/**
* Base constructor
*/
public Log4JCategoryLog(String name) {
// the default log level for log4j should be ALL
// so that control of logging is delegated to Log4J.
// of course, this can be override programmatically for a particular log instance.
setLevel(Log.ALL);
_category = Category.getInstance(name);
category = Category.getInstance(name);
}
// --------------------------------------------------------- Implmentation
// ---------------------------------------------------------- Implmentation
/**
* Simply call log4j category.
*/
protected final void debugImpl(Object message) {
_category.debug(message);
public void debug(Object message) {
category.debug(message);
}
/**
* Simply call log4j category.
*/
protected final void debugImpl(Object message, Throwable t) {
_category.debug(message,t);
public void debug(Object message, Throwable t) {
category.debug(message,t);
}
/**
* Simply call log4j category.
*/
protected final void infoImpl(Object message) {
_category.info(message);
public void info(Object message) {
category.info(message);
}
/**
* Simply call log4j category.
*/
protected final void infoImpl(Object message, Throwable t) {
_category.info(message,t);
public void info(Object message, Throwable t) {
category.info(message,t);
}
/**
* Simply call log4j category.
*/
protected final void warnImpl(Object message) {
_category.warn(message);
public void warn(Object message) {
category.warn(message);
}
/**
* Simply call log4j category.
*/
protected final void warnImpl(Object message, Throwable t) {
_category.warn(message,t);
public void warn(Object message, Throwable t) {
category.warn(message,t);
}
/**
* Simply call log4j category.
*/
protected final void errorImpl(Object message) {
_category.error(message);
public void error(Object message) {
category.error(message);
}
/**
* Simply call log4j category.
*/
protected final void errorImpl(Object message, Throwable t) {
_category.error(message,t);
public void error(Object message, Throwable t) {
category.error(message,t);
}
/**
* Simply call log4j category.
*/
protected final void fatalImpl(Object message) {
_category.fatal(message);
public void fatal(Object message) {
category.fatal(message);
}
/**
* Simply call log4j category.
*/
protected final void fatalImpl(Object message, Throwable t) {
_category.fatal(message,t);
public void fatal(Object message, Throwable t) {
category.fatal(message,t);
}
/**
* Simply call log4j category.
*/
protected final boolean isDebugEnabledImpl() {
return _category.isDebugEnabled();
public boolean isDebugEnabled() {
return category.isDebugEnabled();
}
/**
* Simply call log4j category.
*/
protected final boolean isInfoEnabledImpl() {
return _category.isInfoEnabled();
public boolean isErrorEnabled() {
return category.isEnabledFor(Priority.ERROR);
}
/**
* Simply call log4j category.
*/
public boolean isFatalEnabled() {
return category.isEnabledFor(Priority.FATAL);
}
/**
* Simply call log4j category.
*/
public boolean isInfoEnabled() {
return category.isInfoEnabled();
}
/**
* Simply call log4j category.
*/
public boolean isWarnEnabled() {
return category.isEnabledFor(Priority.WARN);
}
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/LogKitLogger.java,v 1.1 2002/01/07 23:06:10 rdonkin Exp $
* $Revision: 1.1 $
* $Date: 2002/01/07 23:06:10 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/LogKitLogger.java,v 1.2 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.2 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,20 +70,25 @@ import org.apache.log.Hierarchy;
*
* @author Robert Burrell Donkin
*
* @version $Id: LogKitLogger.java,v 1.1 2002/01/07 23:06:10 rdonkin Exp $
* @version $Id: LogKitLogger.java,v 1.2 2002/01/17 01:47:49 craigmcc Exp $
*/
public class LogKitLogger extends AbstractLog {
// --------------------------------------------------------- Attributes
public final class LogKitLogger implements Log {
// ------------------------------------------------------------- Attributes
/** Logging goes to this <code>LogKit</code> logger */
protected Logger logger = null;
// --------------------------------------------------------- Constructor
// ------------------------------------------------------------ Constructor
/**
* Constructor <code>LogKitLogger</code> which wrappers <code>LogKit</code> category with given name.
* Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code>
* logger with given name.
*
* @param name log name
*/
@@ -91,109 +96,148 @@ public class LogKitLogger extends AbstractLog {
logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
}
// --------------------------------------------------------- Log Implementation
// ----------------------------------------------------- Log Implementation
/**
* Log to <code>LogKit</code> logger.
*/
protected final void debugImpl(Object message) {
public void debug(Object message) {
if (message != null) {
logger.debug(message.toString());
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void debugImpl(Object message, Throwable t) {
public void debug(Object message, Throwable t) {
if (message != null) {
logger.debug(message.toString(), t);
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void infoImpl(Object message) {
public void info(Object message) {
if (message != null) {
logger.info(message.toString());
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void infoImpl(Object message, Throwable t) {
public void info(Object message, Throwable t) {
if (message != null) {
logger.info(message.toString(), t);
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void warnImpl(Object message) {
public void warn(Object message) {
if (message != null) {
logger.warn(message.toString());
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void warnImpl(Object message, Throwable t) {
public void warn(Object message, Throwable t) {
if (message != null) {
logger.warn(message.toString(), t);
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void errorImpl(Object message) {
public void error(Object message) {
if (message != null) {
logger.error(message.toString());
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void errorImpl(Object message, Throwable t) {
public void error(Object message, Throwable t) {
if (message != null) {
logger.error(message.toString(), t);
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void fatalImpl(Object message) {
public void fatal(Object message) {
if (message != null) {
logger.fatalError(message.toString());
}
}
/**
* Log to <code>LogKit</code> logger.
*/
protected final void fatalImpl(Object message, Throwable t) {
public void fatal(Object message, Throwable t) {
if (message != null) {
logger.fatalError(message.toString(), t);
}
}
/**
* Check that info is enabled for <code>LogKit</code> logger.
*/
protected boolean isInfoEnabledImpl() {
return logger.isInfoEnabled();
}
/**
* Check that debug is enabled for <code>LogKit</code> logger.
*/
protected boolean isDebugEnabledImpl() {
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
/**
* Check that error is enabled for <code>LogKit</code> logger.
*/
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
/**
* Check that fatal is enabled for <code>LogKit</code> logger.
*/
public boolean isFatalEnabled() {
return logger.isFatalErrorEnabled();
}
/**
* Check that info is enabled for <code>LogKit</code> logger.
*/
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
/**
* Check that warn is enabled for <code>LogKit</code> logger.
*/
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/LogSource.java,v 1.8 2002/01/16 00:54:51 craigmcc Exp $
* $Revision: 1.8 $
* $Date: 2002/01/16 00:54:51 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/LogSource.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.9 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,11 +61,13 @@
package org.apache.commons.logging;
import java.util.HashMap;
import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.lang.reflect.InvocationTargetException;
/**
* <p>Factory for creating {@link Log} instances. Applications should call
* the <code>makeNewLogInstance()</code> method to instantiate new instances
@@ -92,7 +94,7 @@ import java.lang.reflect.InvocationTargetException;
* </ul>
*
* @author Rod Waldhoff
* @version $Id: LogSource.java,v 1.8 2002/01/16 00:54:51 craigmcc Exp $
* @version $Id: LogSource.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
*/
public class LogSource {
@@ -283,17 +285,6 @@ public class LogSource {
}
/**
* Sets the log level for all {@link Log}s known
* to me.
*/
static public void setLevel(int level) {
Iterator it = _logs.entrySet().iterator();
while(it.hasNext()) {
Log log = (Log)(it.next());
log.setLevel(level);
}
}
/**
* Returns a {@link String} array containing the names of
@@ -303,4 +294,5 @@ public class LogSource {
return (String[])(_logs.keySet().toArray(new String[_logs.size()]));
}
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/NoOpLog.java,v 1.7 2002/01/03 18:56:54 rdonkin Exp $
* $Revision: 1.7 $
* $Date: 2002/01/03 18:56:54 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/NoOpLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.8 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@ package org.apache.commons.logging;
* configurable system properties are supported.</p>
*
* @author Rod Waldhoff
* @version $Id: NoOpLog.java,v 1.7 2002/01/03 18:56:54 rdonkin Exp $
* @version $Id: NoOpLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
*/
public final class NoOpLog implements Log {
@@ -103,6 +103,20 @@ public final class NoOpLog implements Log {
*/
public final boolean isDebugEnabled() { return false; }
/**
* Error is never enabled.
*
* @return false
*/
public final boolean isErrorEnabled() { return false; }
/**
* Fatal is never enabled.
*
* @return false
*/
public final boolean isFatalEnabled() { return false; }
/**
* Info is never enabled.
*
@@ -110,12 +124,12 @@ public final class NoOpLog implements Log {
*/
public final boolean isInfoEnabled() { return false; }
/** Do nothing */
public final void setLevel(int level) { }
/**
* Always return off.
* Warning is never enabled.
*
* @return <code>Log.OFF</code>
* @return false
*/
public final int getLevel() { return Log.OFF; }
public final boolean isWarnEnabled() { return false; }
}

View File

@@ -1,13 +1,13 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.7 2002/01/03 19:00:19 rdonkin Exp $
* $Revision: 1.7 $
* $Date: 2002/01/03 19:00:19 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
* $Revision: 1.8 $
* $Date: 2002/01/17 01:47:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -98,11 +98,12 @@ import java.util.Date;
* @author Rod Waldhoff
* @author Robert Burrell Donkin
*
* @version $Id: SimpleLog.java,v 1.7 2002/01/03 19:00:19 rdonkin Exp $
* @version $Id: SimpleLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
*/
public class SimpleLog extends AbstractLog {
// --------------------------------------------------------- Class Attributes
// ------------------------------------------------------- Class Attributes
/** All system properties used by <code>Simple</code> start with this */
static protected final String _prefix =
@@ -119,7 +120,7 @@ public class SimpleLog extends AbstractLog {
// --------------------------------------------------------- Initializer
// ------------------------------------------------------------ Initializer
// initialize class attributes
static {
@@ -165,13 +166,13 @@ public class SimpleLog extends AbstractLog {
}
// --------------------------------------------------------- Attributes
// ------------------------------------------------------------- Attributes
/** The name of this simple log instance */
protected String _name = null;
// --------------------------------------------------------- Constructor
// ------------------------------------------------------------ Constructor
/**
* Construct a simple log with given name.
@@ -213,7 +214,8 @@ public class SimpleLog extends AbstractLog {
}
// --------------------------------------------------------- Methods
// -------------------------------------------------------- Logging Methods
/**
* <p> Do the actual logging.
@@ -259,7 +261,8 @@ public class SimpleLog extends AbstractLog {
System.out.println(buf.toString());
}
// --------------------------------------------------------- Log Implementation
// ----------------------------------------------------- Log Implementation
/**
* Prepare then call {@link #log}.