mirror of https://github.com/apache/poi.git
Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions - triggered by bug #44326
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@617487 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed6038febb
commit
a1718ca9ac
|
@ -36,6 +36,7 @@
|
|||
|
||||
<!-- 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">
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<!-- 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">
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.apache.poi.util;
|
|||
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
|
||||
|
@ -53,7 +51,6 @@ public class CommonsLogger extends POILogger
|
|||
* @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)
|
||||
|
@ -98,6 +95,78 @@ public class CommonsLogger extends POILogger
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,24 @@ public abstract class POILogger
|
|||
|
||||
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
|
||||
|
@ -237,17 +254,15 @@ public abstract class POILogger
|
|||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,8 +49,24 @@ public class SystemOutLogger extends POILogger
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue