diff --git a/src/java/org/apache/poi/util/CommonsLogger.java b/src/java/org/apache/poi/util/CommonsLogger.java index 1cbb9628ca..bbb04af6d1 100644 --- a/src/java/org/apache/poi/util/CommonsLogger.java +++ b/src/java/org/apache/poi/util/CommonsLogger.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; */ public class CommonsLogger extends POILogger { - private static LogFactory _creator = LogFactory.getFactory(); + private static final LogFactory _creator = LogFactory.getFactory(); private Log log = null; @Override @@ -46,8 +46,10 @@ public class CommonsLogger extends POILogger * @param obj1 The object to log. */ @Override - public void log(final int level, final Object obj1) + protected void log(final int level, final Object obj1) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) @@ -100,9 +102,11 @@ public class CommonsLogger extends POILogger * @param exception An exception to be logged */ @Override - public void log(final int level, final Object obj1, + protected void log(final int level, final Object obj1, final Throwable exception) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) @@ -174,6 +178,8 @@ public class CommonsLogger extends POILogger @Override public boolean check(final int level) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) diff --git a/src/java/org/apache/poi/util/NullLogger.java b/src/java/org/apache/poi/util/NullLogger.java index 8a50cffba4..e21adfaa7f 100644 --- a/src/java/org/apache/poi/util/NullLogger.java +++ b/src/java/org/apache/poi/util/NullLogger.java @@ -38,7 +38,7 @@ public class NullLogger extends POILogger { */ @Override - protected void log(final int level, final Object obj1) { + protected void _log(final int level, final Object obj1) { // do nothing } @@ -50,7 +50,7 @@ public class NullLogger extends POILogger { * @param exception An exception to be logged */ @Override - protected void log(int level, Object obj1, final Throwable exception) { + protected void _log(int level, Object obj1, final Throwable exception) { // do nothing } diff --git a/src/java/org/apache/poi/util/POILogger.java b/src/java/org/apache/poi/util/POILogger.java index 9238de01cc..c54c754255 100644 --- a/src/java/org/apache/poi/util/POILogger.java +++ b/src/java/org/apache/poi/util/POILogger.java @@ -54,7 +54,7 @@ public abstract class POILogger { * @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param obj1 The object to log. This is converted to a string. */ - abstract protected void log(int level, Object obj1); + abstract protected void _log(int level, Object obj1); /** * Log a message @@ -63,7 +63,7 @@ public abstract class POILogger { * @param obj1 The object to log. This is converted to a string. * @param exception An exception to be logged */ - abstract protected void log(int level, Object obj1, final Throwable exception); + abstract protected void _log(int level, Object obj1, final Throwable exception); /** @@ -107,9 +107,9 @@ public abstract class POILogger { // somehow this ambiguity works and doesn't lead to a loop, // but it's confusing ... if (lastEx == null) { - log(level, msg); + _log(level, msg); } else { - log(level, msg, lastEx); + _log(level, msg, lastEx); } } } diff --git a/src/java/org/apache/poi/util/SystemOutLogger.java b/src/java/org/apache/poi/util/SystemOutLogger.java index 36d96ca038..457f25410c 100644 --- a/src/java/org/apache/poi/util/SystemOutLogger.java +++ b/src/java/org/apache/poi/util/SystemOutLogger.java @@ -42,9 +42,9 @@ public class SystemOutLogger extends POILogger * @param obj1 The object to log. */ @Override - public void log(final int level, final Object obj1) + protected void _log(final int level, final Object obj1) { - log(level, obj1, null); + _log(level, obj1, null); } /** @@ -56,7 +56,7 @@ public class SystemOutLogger extends POILogger */ @Override @SuppressForbidden("uses printStackTrace") - public void log(final int level, final Object obj1, + protected void _log(final int level, final Object obj1, final Throwable exception) { if (check(level)) { System.out.println("[" + _cat + "]" + LEVEL_STRINGS_SHORT[Math.min(LEVEL_STRINGS_SHORT.length-1, level)] + " " + obj1); diff --git a/src/testcases/org/apache/poi/util/DummyPOILogger.java b/src/testcases/org/apache/poi/util/DummyPOILogger.java index c8566fe663..7da48ce269 100644 --- a/src/testcases/org/apache/poi/util/DummyPOILogger.java +++ b/src/testcases/org/apache/poi/util/DummyPOILogger.java @@ -23,6 +23,7 @@ import java.util.List; * POILogger which logs into an ArrayList, so that * tests can see what got logged */ +@Internal public class DummyPOILogger extends POILogger { public Listlogged = new ArrayList(); @@ -39,12 +40,12 @@ public class DummyPOILogger extends POILogger { public void initialize(String cat) {} @Override - public void log(int level, Object obj1) { + protected void _log(int level, Object obj1) { logged.add(level + " - " + obj1); } @Override - public void log(int level, Object obj1, Throwable exception) { + protected void _log(int level, Object obj1, Throwable exception) { logged.add(level + " - " + obj1 + " - " + exception); } } diff --git a/src/testcases/org/apache/poi/util/TestPOILogger.java b/src/testcases/org/apache/poi/util/TestPOILogger.java index 3914b76436..6650ed9e66 100644 --- a/src/testcases/org/apache/poi/util/TestPOILogger.java +++ b/src/testcases/org/apache/poi/util/TestPOILogger.java @@ -65,13 +65,13 @@ public final class TestPOILogger extends POILogger { } @Override - public void log(int level, Object obj1) { + protected void _log(int level, Object obj1) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = null; } @Override - public void log(int level, Object obj1, Throwable exception) { + protected void _log(int level, Object obj1, Throwable exception) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = exception; }