Update to add a trace() level to the Log interface.
Currently uses debug() in Log4J and LogKit PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138850 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/Attic/Jdk14Logger.java,v 1.4 2002/01/30 03:56:26 craigmcc Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Jdk14Logger.java,v 1.5 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2002/01/30 03:56:26 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -72,9 +72,10 @@ import java.util.logging.Logger;
|
|||||||
* interfaces that wraps the standard JDK logging mechanisms that were
|
* interfaces that wraps the standard JDK logging mechanisms that were
|
||||||
* introduced in the Merlin release (JDK 1.4).</p>
|
* introduced in the Merlin release (JDK 1.4).</p>
|
||||||
*
|
*
|
||||||
|
* @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.4 $ $Date: 2002/01/30 03:56:26 $
|
* @version $Revision: 1.5 $ $Date: 2002/01/31 00:14:31 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class Jdk14Logger implements Log {
|
public final class Jdk14Logger implements Log {
|
||||||
@@ -239,6 +240,16 @@ public final class Jdk14Logger implements Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is tace logging currently enabled?
|
||||||
|
*/
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
|
||||||
|
return (logger.isLoggable(Level.FINEST));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is warning logging currently enabled?
|
* Is warning logging currently enabled?
|
||||||
*/
|
*/
|
||||||
@@ -249,6 +260,26 @@ public final class Jdk14Logger implements Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with trace log level.
|
||||||
|
*/
|
||||||
|
public void trace(Object message) {
|
||||||
|
|
||||||
|
logger.log(Level.FINEST, message.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message and exception with trace log level.
|
||||||
|
*/
|
||||||
|
public void trace(Object message, Throwable exception) {
|
||||||
|
|
||||||
|
logger.log(Level.FINEST, message.toString(), exception);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with warn log level.
|
* Log a message with warn log level.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Log.java,v 1.11 2002/01/23 20:14:30 rdonkin Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Log.java,v 1.12 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.11 $
|
* $Revision: 1.12 $
|
||||||
* $Date: 2002/01/23 20:14:30 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -68,12 +68,13 @@ package org.apache.commons.logging;
|
|||||||
* this interface must have a constructor that takes a single String
|
* 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 five logging levels used by <code>Log</code> are (in order):
|
* <p> The six logging levels used by <code>Log</code> are (in order):
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>debug (the least serious)</li>
|
* <li>trace (the least serious)</li>
|
||||||
|
* <li>debug</li>
|
||||||
* <li>info</li>
|
* <li>info</li>
|
||||||
* <li>warn</li>
|
* <li>warn</li>
|
||||||
* <li>error</li>
|
* <li>error</li>
|
||||||
* <li>fatal (the most serious)</li>
|
* <li>fatal (the most serious)</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
* The mapping of these log levels to the concepts used by the underlying
|
* The mapping of these log levels to the concepts used by the underlying
|
||||||
@@ -86,7 +87,7 @@ package org.apache.commons.logging;
|
|||||||
* a component can avoid expensive operations (producing information
|
* a component can avoid expensive operations (producing information
|
||||||
* to be logged).</p>
|
* to be logged).</p>
|
||||||
*
|
*
|
||||||
* <p> For example,
|
* <p> For example,
|
||||||
* <code><pre>
|
* <code><pre>
|
||||||
* if (log.isDebugEnabled()) {
|
* if (log.isDebugEnabled()) {
|
||||||
* ... do something expensive ...
|
* ... do something expensive ...
|
||||||
@@ -94,109 +95,137 @@ package org.apache.commons.logging;
|
|||||||
* }
|
* }
|
||||||
* </pre></code>
|
* </pre></code>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>Configuration of the underlying logging system will generally be done
|
* <p>Configuration of the underlying logging system will generally be done
|
||||||
* external to the Logging APIs, through whatever mechanism is supported by
|
* external to the Logging APIs, through whatever mechanism is supported by
|
||||||
* that system.</p>
|
* that system.</p>
|
||||||
*
|
*
|
||||||
|
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @version $Id: Log.java,v 1.11 2002/01/23 20:14:30 rdonkin Exp $
|
* @version $Id: Log.java,v 1.12 2002/01/31 00:14:31 sanders Exp $
|
||||||
*/
|
*/
|
||||||
public interface Log {
|
public interface Log {
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- Logging Properties
|
// ----------------------------------------------------- Logging Properties
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Is debug logging currently enabled? </p>
|
* <p> Is debug logging currently enabled? </p>
|
||||||
*
|
*
|
||||||
* <p> Call this method to prevent having to perform expensive operations
|
* <p> Call this method to prevent having to perform expensive operations
|
||||||
* (for example, <code>String</code> concatination)
|
* (for example, <code>String</code> concatination)
|
||||||
* when the log level is more than debug. </p>
|
* when the log level is more than debug. </p>
|
||||||
*/
|
*/
|
||||||
public boolean isDebugEnabled();
|
public boolean isDebugEnabled();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Is error logging currently enabled? </p>
|
* <p> Is error logging currently enabled? </p>
|
||||||
*
|
*
|
||||||
* <p> Call this method to prevent having to perform expensive operations
|
* <p> Call this method to prevent having to perform expensive operations
|
||||||
* (for example, <code>String</code> concatination)
|
* (for example, <code>String</code> concatination)
|
||||||
* when the log level is more than error. </p>
|
* when the log level is more than error. </p>
|
||||||
*/
|
*/
|
||||||
public boolean isErrorEnabled();
|
public boolean isErrorEnabled();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Is fatal logging currently enabled? </p>
|
* <p> Is fatal logging currently enabled? </p>
|
||||||
*
|
*
|
||||||
* <p> Call this method to prevent having to perform expensive operations
|
* <p> Call this method to prevent having to perform expensive operations
|
||||||
* (for example, <code>String</code> concatination)
|
* (for example, <code>String</code> concatination)
|
||||||
* when the log level is more than fatal. </p>
|
* when the log level is more than fatal. </p>
|
||||||
*/
|
*/
|
||||||
public boolean isFatalEnabled();
|
public boolean isFatalEnabled();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Is info logging currently enabled? </p>
|
* <p> Is info logging currently enabled? </p>
|
||||||
*
|
*
|
||||||
* <p> Call this method to prevent having to perform expensive operations
|
* <p> Call this method to prevent having to perform expensive operations
|
||||||
* (for example, <code>String</code> concatination)
|
* (for example, <code>String</code> concatination)
|
||||||
* when the log level is more than info. </p>
|
* when the log level is more than info. </p>
|
||||||
*/
|
*/
|
||||||
public boolean isInfoEnabled();
|
public boolean isInfoEnabled();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Is trace 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 trace. </p>
|
||||||
|
*/
|
||||||
|
public boolean isTraceEnabled();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Is warning logging currently enabled? </p>
|
* <p> Is warning logging currently enabled? </p>
|
||||||
*
|
*
|
||||||
* <p> Call this method to prevent having to perform expensive operations
|
* <p> Call this method to prevent having to perform expensive operations
|
||||||
* (for example, <code>String</code> concatination)
|
* (for example, <code>String</code> concatination)
|
||||||
* when the log level is more than warning. </p>
|
* when the log level is more than warning. </p>
|
||||||
*/
|
*/
|
||||||
public boolean isWarnEnabled();
|
public boolean isWarnEnabled();
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Logging Methods
|
// -------------------------------------------------------- Logging Methods
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with debug log level </p>
|
* <p> Log a message with trace log level </p>
|
||||||
|
*
|
||||||
|
* @param message log this message
|
||||||
|
*/
|
||||||
|
public void trace(Object message);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Log an error with trace log level </p>
|
||||||
|
*
|
||||||
|
* @param message log this message
|
||||||
|
* @param t log this cause
|
||||||
|
*/
|
||||||
|
public void trace(Object message, Throwable t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Log a message with debug log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
*/
|
*/
|
||||||
public void debug(Object message);
|
public void debug(Object message);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with debug log level </p>
|
* <p> Log an error with debug log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
* @param t log this cause
|
* @param t log this cause
|
||||||
*/
|
*/
|
||||||
public void debug(Object message, Throwable t);
|
public void debug(Object message, Throwable t);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with info log level </p>
|
* <p> Log a message with info log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
*/
|
*/
|
||||||
public void info(Object message);
|
public void info(Object message);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with info log level </p>
|
* <p> Log an error with info log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
* @param t log this cause
|
* @param t log this cause
|
||||||
*/
|
*/
|
||||||
public void info(Object message, Throwable t);
|
public void info(Object message, Throwable t);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with warn log level </p>
|
* <p> Log a message with warn log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
*/
|
*/
|
||||||
@@ -204,16 +233,16 @@ public interface Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with warn log level </p>
|
* <p> Log an error with warn log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
* @param t log this cause
|
* @param t log this cause
|
||||||
*/
|
*/
|
||||||
public void warn(Object message, Throwable t);
|
public void warn(Object message, Throwable t);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with error log level </p>
|
* <p> Log a message with error log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
*/
|
*/
|
||||||
@@ -221,16 +250,16 @@ public interface Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with error log level </p>
|
* <p> Log an error with error log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
* @param t log this cause
|
* @param t log this cause
|
||||||
*/
|
*/
|
||||||
public void error(Object message, Throwable t);
|
public void error(Object message, Throwable t);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with fatal log level </p>
|
* <p> Log a message with fatal log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
*/
|
*/
|
||||||
@@ -238,7 +267,7 @@ public interface Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with fatal log level </p>
|
* <p> Log an error with fatal log level </p>
|
||||||
*
|
*
|
||||||
* @param message log this message
|
* @param message log this message
|
||||||
* @param t log this cause
|
* @param t log this cause
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Log4JCategoryLog.java,v 1.9 2002/01/24 18:29:36 rdonkin Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/Log4JCategoryLog.java,v 1.10 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.9 $
|
* $Revision: 1.10 $
|
||||||
* $Date: 2002/01/24 18:29:36 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -71,26 +71,26 @@ import org.apache.log4j.Priority;
|
|||||||
* Category instances should be done in the usual manner, as outlined in
|
* Category instances should be done in the usual manner, as outlined in
|
||||||
* the Log4J documentation.</p>
|
* the Log4J documentation.</p>
|
||||||
*
|
*
|
||||||
|
* @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: Log4JCategoryLog.java,v 1.10 2002/01/31 00:14:31 sanders Exp $
|
||||||
* @version $Id: Log4JCategoryLog.java,v 1.9 2002/01/24 18:29:36 rdonkin Exp $
|
|
||||||
*/
|
*/
|
||||||
public final class Log4JCategoryLog implements Log {
|
public final class Log4JCategoryLog implements Log {
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------- Attributes
|
// ------------------------------------------------------------- Attributes
|
||||||
|
|
||||||
|
|
||||||
/** Log to this category */
|
/** Log to this category */
|
||||||
Category category = null;
|
Category category = null;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
// ------------------------------------------------------------ Constructor
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base constructor
|
* Base constructor
|
||||||
*/
|
*/
|
||||||
public Log4JCategoryLog(String name) {
|
public Log4JCategoryLog(String name) {
|
||||||
category = Category.getInstance(name);
|
category = Category.getInstance(name);
|
||||||
@@ -100,6 +100,24 @@ public final class Log4JCategoryLog implements Log {
|
|||||||
// ---------------------------------------------------------- Implmentation
|
// ---------------------------------------------------------- Implmentation
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message to the Log4j Category with <code>TRACE</code> priority.
|
||||||
|
* Currently logs to <code>DEBUG</code> level in Log4J.
|
||||||
|
*/
|
||||||
|
public void trace(Object message) {
|
||||||
|
category.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an error to the Log4j Category with <code>TRACE</code> priority.
|
||||||
|
* Currently logs to <code>DEBUG</code> level in Log4J.
|
||||||
|
*/
|
||||||
|
public void trace(Object message, Throwable t) {
|
||||||
|
category.debug(message,t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message to the Log4j Category with <code>DEBUG</code> priority.
|
* Log a message to the Log4j Category with <code>DEBUG</code> priority.
|
||||||
*/
|
*/
|
||||||
@@ -139,7 +157,7 @@ public final class Log4JCategoryLog implements Log {
|
|||||||
category.warn(message);
|
category.warn(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an error to the Log4j Category with <code>WARN</code> priority.
|
* Log an error to the Log4j Category with <code>WARN</code> priority.
|
||||||
*/
|
*/
|
||||||
@@ -212,6 +230,14 @@ public final class Log4JCategoryLog implements Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the Log4j Category used is enabled for <code>TRACE</code> priority.
|
||||||
|
* For Log4J, this returns the value of <code>isDebugEnabled()</code>
|
||||||
|
*/
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return category.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the Log4j Category used is enabled for <code>WARN</code> priority.
|
* Check whether the Log4j Category used is enabled for <code>WARN</code> priority.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/LogKitLogger.java,v 1.3 2002/01/24 19:02:35 rdonkin Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/LogKitLogger.java,v 1.4 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2002/01/24 19:02:35 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -66,17 +66,17 @@ import org.apache.log.Logger;
|
|||||||
import org.apache.log.Hierarchy;
|
import org.apache.log.Hierarchy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Implementation of <code>org.apache.commons.logging.Log</code>
|
* <p>Implementation of <code>org.apache.commons.logging.Log</code>
|
||||||
* that wraps the <a href="http://jakarta.apache.org/avalon/logkit/">jakarta-avalon-logkit</a>
|
* that wraps the <a href="http://jakarta.apache.org/avalon/logkit/">jakarta-avalon-logkit</a>
|
||||||
* logging system. Configuration of <code>LogKit</code> is left to the user.</p>
|
* logging system. Configuration of <code>LogKit</code> is left to the user.</p>
|
||||||
*
|
*
|
||||||
* <p><code>LogKit</code> accepts only <code>String</code> messages.
|
* <p><code>LogKit</code> accepts only <code>String</code> messages.
|
||||||
* Therefore, this implementation converts object messages into strings
|
* Therefore, this implementation converts object messages into strings
|
||||||
* by called their <code>toString()</code> method before logging them.</p>
|
* by called their <code>toString()</code> method before logging them.</p>
|
||||||
*
|
*
|
||||||
* @author Robert Burrell Donkin
|
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||||
*
|
* @author Robert Burrell Donkin *
|
||||||
* @version $Id: LogKitLogger.java,v 1.3 2002/01/24 19:02:35 rdonkin Exp $
|
* @version $Id: LogKitLogger.java,v 1.4 2002/01/31 00:14:31 sanders Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class LogKitLogger implements Log {
|
public final class LogKitLogger implements Log {
|
||||||
@@ -90,12 +90,12 @@ public final class LogKitLogger implements Log {
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
// ------------------------------------------------------------ Constructor
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code>
|
* Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code>
|
||||||
* logger with given name.
|
* logger with given name.
|
||||||
*
|
*
|
||||||
* @param name log name
|
* @param name log name
|
||||||
*/
|
*/
|
||||||
public LogKitLogger(String name) {
|
public LogKitLogger(String name) {
|
||||||
@@ -106,6 +106,22 @@ public final class LogKitLogger implements Log {
|
|||||||
// ----------------------------------------------------- Log Implementation
|
// ----------------------------------------------------- Log Implementation
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log message to <code>LogKit</code> logger with <code>DEBUG</code> priority.
|
||||||
|
*/
|
||||||
|
public void trace(Object message) {
|
||||||
|
debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log error to <code>LogKit</code> logger with <code>DEBUG</code> priority.
|
||||||
|
*/
|
||||||
|
public void trace(Object message, Throwable t) {
|
||||||
|
debug(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log message to <code>LogKit</code> logger with <code>DEBUG</code> priority.
|
* Log message to <code>LogKit</code> logger with <code>DEBUG</code> priority.
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +170,7 @@ public final class LogKitLogger implements Log {
|
|||||||
logger.warn(message.toString());
|
logger.warn(message.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log error to <code>LogKit</code> logger with <code>WARN</code> priority.
|
* Log error to <code>LogKit</code> logger with <code>WARN</code> priority.
|
||||||
@@ -208,7 +224,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 logger.isDebugEnabled();
|
||||||
}
|
}
|
||||||
@@ -216,7 +232,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 logger.isErrorEnabled();
|
||||||
}
|
}
|
||||||
@@ -224,7 +240,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 logger.isFatalErrorEnabled();
|
||||||
}
|
}
|
||||||
@@ -232,15 +248,23 @@ 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 logger.isInfoEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the <code>LogKit</code> logger will log messages of priority <code>DEBUG</code>.
|
||||||
|
*/
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 logger.isWarnEnabled();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $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 $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/NoOpLog.java,v 1.9 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.8 $
|
* $Revision: 1.9 $
|
||||||
* $Date: 2002/01/17 01:47:49 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -66,8 +66,9 @@ package org.apache.commons.logging;
|
|||||||
* <p>Default implementation of Log that throws away all messages. No
|
* <p>Default implementation of Log that throws away all messages. No
|
||||||
* configurable system properties are supported.</p>
|
* configurable system properties are supported.</p>
|
||||||
*
|
*
|
||||||
|
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @version $Id: NoOpLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
|
* @version $Id: NoOpLog.java,v 1.9 2002/01/31 00:14:31 sanders Exp $
|
||||||
*/
|
*/
|
||||||
public final class NoOpLog implements Log {
|
public final class NoOpLog implements Log {
|
||||||
|
|
||||||
@@ -76,6 +77,10 @@ public final class NoOpLog implements Log {
|
|||||||
/** Base constructor */
|
/** Base constructor */
|
||||||
public NoOpLog(String name) { }
|
public NoOpLog(String name) { }
|
||||||
/** Do nothing */
|
/** Do nothing */
|
||||||
|
public void trace(Object message) { }
|
||||||
|
/** Do nothing */
|
||||||
|
public void trace(Object message, Throwable t) { }
|
||||||
|
/** Do nothing */
|
||||||
public void debug(Object message) { }
|
public void debug(Object message) { }
|
||||||
/** Do nothing */
|
/** Do nothing */
|
||||||
public void debug(Object message, Throwable t) { }
|
public void debug(Object message, Throwable t) { }
|
||||||
@@ -96,40 +101,46 @@ public final class NoOpLog implements Log {
|
|||||||
/** Do nothing */
|
/** Do nothing */
|
||||||
public void fatal(Object message, Throwable t) { }
|
public void fatal(Object message, Throwable t) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug is never enabled.
|
* Debug is never enabled.
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public final boolean isDebugEnabled() { return false; }
|
public final boolean isDebugEnabled() { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error is never enabled.
|
* Error is never enabled.
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public final boolean isErrorEnabled() { return false; }
|
public final boolean isErrorEnabled() { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fatal is never enabled.
|
* Fatal is never enabled.
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public final boolean isFatalEnabled() { return false; }
|
public final boolean isFatalEnabled() { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Info is never enabled.
|
* Info is never enabled.
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public final boolean isInfoEnabled() { return false; }
|
public final boolean isInfoEnabled() { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning is never enabled.
|
* Trace is never enabled.
|
||||||
|
*
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
public final boolean isTraceEnabled() { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning is never enabled.
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public final boolean isWarnEnabled() { return false; }
|
public final boolean isWarnEnabled() { return false; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.11 2002/01/25 18:41:48 sanders Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.12 2002/01/31 00:14:31 sanders Exp $
|
||||||
* $Revision: 1.11 $
|
* $Revision: 1.12 $
|
||||||
* $Date: 2002/01/25 18:41:48 $
|
* $Date: 2002/01/31 00:14:31 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -76,11 +76,11 @@ import java.util.Date;
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li><code>org.apache.commons.logging.simplelog.defaultlog</code> -
|
* <li><code>org.apache.commons.logging.simplelog.defaultlog</code> -
|
||||||
* Default logging detail level for all instances of SimpleLog.
|
* Default logging detail level for all instances of SimpleLog.
|
||||||
* Must be one of ("debug", "info", "warn", "error", or "fatal").
|
* Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
|
||||||
* If not specified, defaults to "error". </li>
|
* If not specified, defaults to "error". </li>
|
||||||
* <li><code>org.apache.commons.logging.simplelog.log.xxxxx</code> -
|
* <li><code>org.apache.commons.logging.simplelog.log.xxxxx</code> -
|
||||||
* Logging detail level for a SimpleLog instance named "xxxxx".
|
* Logging detail level for a SimpleLog instance named "xxxxx".
|
||||||
* Must be one of ("debug", "info", "warn", "error", or "fatal").
|
* Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
|
||||||
* If not specified, the default logging detail level is used.</li>
|
* If not specified, the default logging detail level is used.</li>
|
||||||
* <li><code>org.apache.commons.logging.simplelog.showlogname</code> -
|
* <li><code>org.apache.commons.logging.simplelog.showlogname</code> -
|
||||||
* Set to <code>true</code> if you want the Log instance name to be
|
* Set to <code>true</code> if you want the Log instance name to be
|
||||||
@@ -95,20 +95,21 @@ import java.util.Date;
|
|||||||
* <code>"simplelog.properties"</code>, and includes any matching definitions
|
* <code>"simplelog.properties"</code>, and includes any matching definitions
|
||||||
* from this resource (if it exists).</p>
|
* from this resource (if it exists).</p>
|
||||||
*
|
*
|
||||||
|
* @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: SimpleLog.java,v 1.11 2002/01/25 18:41:48 sanders Exp $
|
* @version $Id: SimpleLog.java,v 1.12 2002/01/31 00:14:31 sanders Exp $
|
||||||
*/
|
*/
|
||||||
public class SimpleLog implements Log {
|
public class SimpleLog implements Log {
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------- Class Attributes
|
// ------------------------------------------------------- Class Attributes
|
||||||
|
|
||||||
/** All system properties used by <code>Simple</code> start with this */
|
/** All system properties used by <code>Simple</code> start with this */
|
||||||
static protected final String systemPrefix =
|
static protected final String systemPrefix =
|
||||||
"org.apache.commons.logging.simplelog.";
|
"org.apache.commons.logging.simplelog.";
|
||||||
|
|
||||||
/** All system properties which start with {@link #systemPrefix} */
|
/** All system properties which start with {@link #systemPrefix} */
|
||||||
static protected final Properties simpleLogProps = new Properties();
|
static protected final Properties simpleLogProps = new Properties();
|
||||||
/** Include the instance name in the log message? */
|
/** Include the instance name in the log message? */
|
||||||
@@ -119,21 +120,23 @@ public class SimpleLog implements Log {
|
|||||||
static protected DateFormat dateFormatter = null;
|
static protected DateFormat dateFormatter = null;
|
||||||
|
|
||||||
// ---------------------------------------------------- Log Level Constants
|
// ---------------------------------------------------- Log Level Constants
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** "Trace" level logging. */
|
||||||
|
public static final int LOG_LEVEL_TRACE = 1;
|
||||||
/** "Debug" level logging. */
|
/** "Debug" level logging. */
|
||||||
public static final int LOG_LEVEL_DEBUG = 1;
|
public static final int LOG_LEVEL_DEBUG = 2;
|
||||||
/** "Info" level logging. */
|
/** "Info" level logging. */
|
||||||
public static final int LOG_LEVEL_INFO = 2;
|
public static final int LOG_LEVEL_INFO = 3;
|
||||||
/** "Warn" level logging. */
|
/** "Warn" level logging. */
|
||||||
public static final int LOG_LEVEL_WARN = 3;
|
public static final int LOG_LEVEL_WARN = 4;
|
||||||
/** "Error" level logging. */
|
/** "Error" level logging. */
|
||||||
public static final int LOG_LEVEL_ERROR = 4;
|
public static final int LOG_LEVEL_ERROR = 5;
|
||||||
/** "Fatal" level logging. */
|
/** "Fatal" level logging. */
|
||||||
public static final int LOG_LEVEL_FATAL = 5;
|
public static final int LOG_LEVEL_FATAL = 6;
|
||||||
|
|
||||||
/** Enable all logging levels */
|
/** Enable all logging levels */
|
||||||
public static final int LOG_LEVEL_ALL = (LOG_LEVEL_DEBUG - 1);
|
public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1);
|
||||||
|
|
||||||
/** Enable no logging levels */
|
/** Enable no logging levels */
|
||||||
public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1);
|
public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1);
|
||||||
@@ -162,15 +165,15 @@ public class SimpleLog implements Log {
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showLogName = "true".equalsIgnoreCase(
|
showLogName = "true".equalsIgnoreCase(
|
||||||
simpleLogProps.getProperty(
|
simpleLogProps.getProperty(
|
||||||
systemPrefix + "showlogname","true"));
|
systemPrefix + "showlogname","true"));
|
||||||
|
|
||||||
showDateTime = "true".equalsIgnoreCase(
|
showDateTime = "true".equalsIgnoreCase(
|
||||||
simpleLogProps.getProperty(
|
simpleLogProps.getProperty(
|
||||||
systemPrefix + "showdatetime","true"));
|
systemPrefix + "showdatetime","true"));
|
||||||
|
|
||||||
if(showDateTime) {
|
if(showDateTime) {
|
||||||
dateFormatter = new SimpleDateFormat(
|
dateFormatter = new SimpleDateFormat(
|
||||||
simpleLogProps.getProperty(
|
simpleLogProps.getProperty(
|
||||||
@@ -188,20 +191,20 @@ public class SimpleLog implements Log {
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
// ------------------------------------------------------------ Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a simple log with given name.
|
* Construct a simple log with given name.
|
||||||
*
|
*
|
||||||
* @param name log name
|
* @param name log name
|
||||||
*/
|
*/
|
||||||
public SimpleLog(String name) {
|
public SimpleLog(String name) {
|
||||||
|
|
||||||
logName = name;
|
logName = name;
|
||||||
|
|
||||||
// set initial log level
|
// set initial log level
|
||||||
// set default log level to ERROR
|
// set default log level to ERROR
|
||||||
setLevel(SimpleLog.LOG_LEVEL_ERROR);
|
setLevel(SimpleLog.LOG_LEVEL_ERROR);
|
||||||
|
|
||||||
// set log level from properties
|
// set log level from properties
|
||||||
String lvl = simpleLogProps.getProperty(systemPrefix + "log." + logName);
|
String lvl = simpleLogProps.getProperty(systemPrefix + "log." + logName);
|
||||||
int i = String.valueOf(name).lastIndexOf(".");
|
int i = String.valueOf(name).lastIndexOf(".");
|
||||||
@@ -210,13 +213,15 @@ public class SimpleLog implements Log {
|
|||||||
lvl = simpleLogProps.getProperty(systemPrefix + "log." + name);
|
lvl = simpleLogProps.getProperty(systemPrefix + "log." + name);
|
||||||
i = String.valueOf(name).lastIndexOf(".");
|
i = String.valueOf(name).lastIndexOf(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(null == lvl) {
|
if(null == lvl) {
|
||||||
lvl = simpleLogProps.getProperty(systemPrefix + "defaultlog");
|
lvl = simpleLogProps.getProperty(systemPrefix + "defaultlog");
|
||||||
}
|
}
|
||||||
|
|
||||||
if("all".equalsIgnoreCase(lvl)) {
|
if("all".equalsIgnoreCase(lvl)) {
|
||||||
setLevel(SimpleLog.LOG_LEVEL_ALL);
|
setLevel(SimpleLog.LOG_LEVEL_ALL);
|
||||||
|
} else if("trace".equalsIgnoreCase(lvl)) {
|
||||||
|
setLevel(SimpleLog.LOG_LEVEL_TRACE);
|
||||||
} else if("debug".equalsIgnoreCase(lvl)) {
|
} else if("debug".equalsIgnoreCase(lvl)) {
|
||||||
setLevel(SimpleLog.LOG_LEVEL_DEBUG);
|
setLevel(SimpleLog.LOG_LEVEL_DEBUG);
|
||||||
} else if("info".equalsIgnoreCase(lvl)) {
|
} else if("info".equalsIgnoreCase(lvl)) {
|
||||||
@@ -235,62 +240,63 @@ public class SimpleLog implements Log {
|
|||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Properties
|
// -------------------------------------------------------- Properties
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Set logging level. </p>
|
* <p> Set logging level. </p>
|
||||||
*
|
*
|
||||||
* @param level new logging level
|
* @param level new logging level
|
||||||
*/
|
*/
|
||||||
public void setLevel(int currentLogLevel) {
|
public void setLevel(int currentLogLevel) {
|
||||||
|
|
||||||
this.currentLogLevel = currentLogLevel;
|
this.currentLogLevel = currentLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Get logging level. </p>
|
* <p> Get logging level. </p>
|
||||||
*/
|
*/
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
|
|
||||||
return currentLogLevel;
|
return currentLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Logging Methods
|
// -------------------------------------------------------- Logging Methods
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Do the actual logging.
|
* <p> Do the actual logging.
|
||||||
* This method assembles the message
|
* This method assembles the message
|
||||||
* and then prints to <code>System.out</code>.</p>
|
* and then prints to <code>System.out</code>.</p>
|
||||||
*/
|
*/
|
||||||
protected void log(int type, Object message, Throwable t) {
|
protected void log(int type, Object message, Throwable t) {
|
||||||
// use a string buffer for better performance
|
// use a string buffer for better performance
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
// append date-time if so configured
|
// append date-time if so configured
|
||||||
if(showDateTime) {
|
if(showDateTime) {
|
||||||
buf.append(dateFormatter.format(new Date()));
|
buf.append(dateFormatter.format(new Date()));
|
||||||
buf.append(" ");
|
buf.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// append a readable representation of the log leve
|
// append a readable representation of the log leve
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
case SimpleLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break;
|
||||||
case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break;
|
case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break;
|
||||||
case SimpleLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break;
|
case SimpleLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break;
|
||||||
case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break;
|
case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break;
|
||||||
case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
|
case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
|
||||||
case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
|
case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// append the name of the log instance if so configured
|
// append the name of the log instance if so configured
|
||||||
if(showLogName) {
|
if(showLogName) {
|
||||||
buf.append(String.valueOf(logName)).append(" - ");
|
buf.append(String.valueOf(logName)).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// append the message
|
// append the message
|
||||||
buf.append(String.valueOf(message));
|
buf.append(String.valueOf(message));
|
||||||
|
|
||||||
// append stack trace if not null
|
// append stack trace if not null
|
||||||
if(t != null) {
|
if(t != null) {
|
||||||
buf.append(" <");
|
buf.append(" <");
|
||||||
@@ -298,7 +304,7 @@ public class SimpleLog implements Log {
|
|||||||
buf.append(">");
|
buf.append(">");
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// print to System.out
|
// print to System.out
|
||||||
System.out.println(buf.toString());
|
System.out.println(buf.toString());
|
||||||
}
|
}
|
||||||
@@ -314,27 +320,27 @@ public class SimpleLog implements Log {
|
|||||||
// comparison
|
// comparison
|
||||||
return (logLevel >= currentLogLevel);
|
return (logLevel >= currentLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Log Implementation
|
// -------------------------------------------------------- Log Implementation
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with debug log level.</p>
|
* <p> Log a message with debug log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void debug(Object message) {
|
public final void debug(Object message) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
|
||||||
log(SimpleLog.LOG_LEVEL_DEBUG, message, null);
|
log(SimpleLog.LOG_LEVEL_DEBUG, message, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with debug log level.</p>
|
* <p> Log an error with debug log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void debug(Object message, Throwable t) {
|
public final void debug(Object message, Throwable t) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
|
||||||
log(SimpleLog.LOG_LEVEL_DEBUG, message, t);
|
log(SimpleLog.LOG_LEVEL_DEBUG, message, t);
|
||||||
}
|
}
|
||||||
@@ -342,32 +348,54 @@ public class SimpleLog implements Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with info log level.</p>
|
* <p> Log a message with debug log level.</p>
|
||||||
*/
|
*/
|
||||||
|
public final void trace(Object message) {
|
||||||
|
|
||||||
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
|
||||||
|
log(SimpleLog.LOG_LEVEL_TRACE, message, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Log an error with debug log level.</p>
|
||||||
|
*/
|
||||||
|
public final void trace(Object message, Throwable t) {
|
||||||
|
|
||||||
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
|
||||||
|
log(SimpleLog.LOG_LEVEL_TRACE, message, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Log a message with info log level.</p>
|
||||||
|
*/
|
||||||
public final void info(Object message) {
|
public final void info(Object message) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
|
||||||
log(SimpleLog.LOG_LEVEL_INFO,message,null);
|
log(SimpleLog.LOG_LEVEL_INFO,message,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with info log level.</p>
|
* <p> Log an error with info log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void info(Object message, Throwable t) {
|
public final void info(Object message, Throwable t) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
|
||||||
log(SimpleLog.LOG_LEVEL_INFO, message, t);
|
log(SimpleLog.LOG_LEVEL_INFO, message, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with warn log level.</p>
|
* <p> Log a message with warn log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void warn(Object message) {
|
public final void warn(Object message) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
|
||||||
log(SimpleLog.LOG_LEVEL_WARN, message, null);
|
log(SimpleLog.LOG_LEVEL_WARN, message, null);
|
||||||
}
|
}
|
||||||
@@ -375,43 +403,43 @@ public class SimpleLog implements Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with warn log level.</p>
|
* <p> Log an error with warn log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void warn(Object message, Throwable t) {
|
public final void warn(Object message, Throwable t) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
|
||||||
log(SimpleLog.LOG_LEVEL_WARN, message, t);
|
log(SimpleLog.LOG_LEVEL_WARN, message, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with error log level.</p>
|
* <p> Log a message with error log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void error(Object message) {
|
public final void error(Object message) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
|
||||||
log(SimpleLog.LOG_LEVEL_ERROR, message, null);
|
log(SimpleLog.LOG_LEVEL_ERROR, message, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with error log level.</p>
|
* <p> Log an error with error log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void error(Object message, Throwable t) {
|
public final void error(Object message, Throwable t) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
|
||||||
log(SimpleLog.LOG_LEVEL_ERROR, message, t);
|
log(SimpleLog.LOG_LEVEL_ERROR, message, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log a message with fatal log level.</p>
|
* <p> Log a message with fatal log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void fatal(Object message) {
|
public final void fatal(Object message) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
|
||||||
log(SimpleLog.LOG_LEVEL_FATAL, message, null);
|
log(SimpleLog.LOG_LEVEL_FATAL, message, null);
|
||||||
}
|
}
|
||||||
@@ -419,16 +447,16 @@ public class SimpleLog implements Log {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Log an error with fatal log level.</p>
|
* <p> Log an error with fatal log level.</p>
|
||||||
*/
|
*/
|
||||||
public final void fatal(Object message, Throwable t) {
|
public final void fatal(Object message, Throwable t) {
|
||||||
|
|
||||||
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
|
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
|
||||||
log(SimpleLog.LOG_LEVEL_FATAL, message, t);
|
log(SimpleLog.LOG_LEVEL_FATAL, message, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Are debug messages currently enabled? </p>
|
* <p> Are debug messages currently enabled? </p>
|
||||||
*
|
*
|
||||||
@@ -437,10 +465,10 @@ public class SimpleLog implements Log {
|
|||||||
* logger. </p>
|
* logger. </p>
|
||||||
*/
|
*/
|
||||||
public final boolean isDebugEnabled() {
|
public final boolean isDebugEnabled() {
|
||||||
|
|
||||||
return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG);
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Are error messages currently enabled? </p>
|
* <p> Are error messages currently enabled? </p>
|
||||||
@@ -450,10 +478,10 @@ public class SimpleLog implements Log {
|
|||||||
* logger. </p>
|
* logger. </p>
|
||||||
*/
|
*/
|
||||||
public final boolean isErrorEnabled() {
|
public final boolean isErrorEnabled() {
|
||||||
|
|
||||||
return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR);
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Are fatal messages currently enabled? </p>
|
* <p> Are fatal messages currently enabled? </p>
|
||||||
@@ -463,10 +491,10 @@ public class SimpleLog implements Log {
|
|||||||
* logger. </p>
|
* logger. </p>
|
||||||
*/
|
*/
|
||||||
public final boolean isFatalEnabled() {
|
public final boolean isFatalEnabled() {
|
||||||
|
|
||||||
return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL);
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Are info messages currently enabled? </p>
|
* <p> Are info messages currently enabled? </p>
|
||||||
@@ -476,11 +504,24 @@ public class SimpleLog implements Log {
|
|||||||
* logger. </p>
|
* logger. </p>
|
||||||
*/
|
*/
|
||||||
public final boolean isInfoEnabled() {
|
public final boolean isInfoEnabled() {
|
||||||
|
|
||||||
return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Are trace messages currently enabled? </p>
|
||||||
|
*
|
||||||
|
* <p> This allows expensive operations such as <code>String</code>
|
||||||
|
* concatenation to be avoided when the message will be ignored by the
|
||||||
|
* logger. </p>
|
||||||
|
*/
|
||||||
|
public final boolean isTraceEnabled() {
|
||||||
|
|
||||||
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Are warn messages currently enabled? </p>
|
* <p> Are warn messages currently enabled? </p>
|
||||||
*
|
*
|
||||||
@@ -489,7 +530,7 @@ public class SimpleLog implements Log {
|
|||||||
* logger. </p>
|
* logger. </p>
|
||||||
*/
|
*/
|
||||||
public final boolean isWarnEnabled() {
|
public final boolean isWarnEnabled() {
|
||||||
|
|
||||||
return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN);
|
return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user