<!-- Don't forget to update status.xml too! -->
<release version="3.1-beta1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>
<action dev="POI-DEVELOPERS" type="add">Support for a completed Record based "pull" stream, via org.apache.poi.hssf.eventusermodel.HSSFRecordStream, to complement the existing "push" Event User Model listener stuff</action>
</release>
<release version="3.0.2-FINAL" date="2008-02-04">
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1-beta1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>
<action dev="POI-DEVELOPERS" type="add">Support for a completed Record based "pull" stream, via org.apache.poi.hssf.eventusermodel.HSSFRecordStream, to complement the existing "push" Event User Model listener stuff</action>
</release>
<release version="3.0.2-FINAL" date="2008-02-04">
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.*;
-
/**
* A logger class that strives to make it as easy as possible for
* developers to write log calls, while simultaneously making those
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log.
*/
-
public void log(final int level, final Object obj1)
{
if(level==FATAL)
log.trace(obj1);
}
}
+ }
+
+ /**
+ * Log a message
+ *
+ * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+ * @param obj1 The object to log. This is converted to a string.
+ * @param exception An exception to be logged
+ */
+ public void log(final int level, final Object obj1,
+ final Throwable exception)
+ {
+ if(level==FATAL)
+ {
+ if(log.isFatalEnabled())
+ {
+ if(obj1 != null)
+ log.fatal(obj1, exception);
+ else
+ log.fatal(exception);
+ }
+ }
+ else if(level==ERROR)
+ {
+ if(log.isErrorEnabled())
+ {
+ if(obj1 != null)
+ log.error(obj1, exception);
+ else
+ log.error(exception);
+ }
+ }
+ else if(level==WARN)
+ {
+ if(log.isWarnEnabled())
+ {
+ if(obj1 != null)
+ log.warn(obj1, exception);
+ else
+ log.warn(exception);
+ }
+ }
+ else if(level==INFO)
+ {
+ if(log.isInfoEnabled())
+ {
+ if(obj1 != null)
+ log.info(obj1, exception);
+ else
+ log.info(exception);
+ }
+ }
+ else if(level==DEBUG)
+ {
+ if(log.isDebugEnabled())
+ {
+ if(obj1 != null)
+ log.debug(obj1, exception);
+ else
+ log.debug(exception);
+ }
+ }
+ else
+ {
+ if(log.isTraceEnabled())
+ {
+ if(obj1 != null)
+ log.trace(obj1, exception);
+ else
+ log.trace(exception);
+ }
+ }
}
abstract public void initialize(final String cat);
+ /**
+ * Log a message
+ *
+ * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+ * @param obj1 The object to log. This is converted to a string.
+ */
abstract public void log(final int level, final Object obj1);
+
+ /**
+ * Log a message
+ *
+ * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+ * @param obj1 The object to log. This is converted to a string.
+ * @param exception An exception to be logged
+ */
+ abstract public void log(final int level, final Object obj1,
+ final Throwable exception);
+
/**
* Check if a logger is enabled to log at the specified level
}
/**
- * Log a message
+ * Log an exception, without a message
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged
*/
- public void log(final int level, final Object obj1,
- final Throwable exception)
+ public void log(final int level, final Throwable exception)
{
- log(level , obj1, exception);
+ log(level, null, exception);
}
/**
public void log(final int level, final Object obj1)
{
- if (check(level))
+ log(level, obj1, null);
+ }
+
+ /**
+ * Log a message
+ *
+ * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+ * @param obj1 The object to log. This is converted to a string.
+ * @param exception An exception to be logged
+ */
+ public void log(final int level, final Object obj1,
+ final Throwable exception) {
+ if (check(level)) {
System.out.println("["+cat+"] "+obj1);
+ if(exception != null) {
+ exception.printStackTrace(System.out);
+ }
+ }
}
/**