logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1390458 - in /logging/log4j/log4j2/trunk: api/src/main/java/org/apache/logging/log4j/spi/ api/src/main/java/org/apache/logging/log4j/status/ api/src/test/java/org/apache/logging/log4j/ core/src/main/java/org/apache/logging/log4j/core/ src/...
Date Wed, 26 Sep 2012 13:15:55 GMT
Author: rgoers
Date: Wed Sep 26 13:15:54 2012
New Revision: 1390458

URL: http://svn.apache.org/viewvc?rev=1390458&view=rev
Log:
LOG4J2-88 - Many logging methods in AbstractLogger were set to an incorrect logging level

Added:
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
Wed Sep 26 13:15:54 2012
@@ -138,8 +138,8 @@ public abstract class AbstractLogger imp
      * @param t The Throwable.
      */
     public void catching(Throwable t) {
-        if (isEnabled(Level.DEBUG, THROWING_MARKER, (Object) null, null)) {
-            log(THROWING_MARKER, FQCN, Level.DEBUG, new SimpleMessage("catching"), t);
+        if (isEnabled(Level.DEBUG, CATCHING_MARKER, (Object) null, null)) {
+            log(CATCHING_MARKER, FQCN, Level.ERROR, new SimpleMessage("catching"), t);
         }
     }
 
@@ -150,8 +150,8 @@ public abstract class AbstractLogger imp
      * @param t     The Throwable.
      */
     public void catching(Level level, Throwable t) {
-        if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
-            log(THROWING_MARKER, FQCN, level, new SimpleMessage("catching"), t);
+        if (isEnabled(level, CATCHING_MARKER, (Object) null, null)) {
+            log(CATCHING_MARKER, FQCN, level, new SimpleMessage("catching"), t);
         }
     }
 
@@ -521,8 +521,8 @@ public abstract class AbstractLogger imp
      * @param msg the message string to be logged
      */
     public void debug(Message msg) {
-        if (isEnabled(Level.TRACE, null, msg, null)) {
-            log(null, FQCN, Level.TRACE, msg, null);
+        if (isEnabled(Level.DEBUG, null, msg, null)) {
+            log(null, FQCN, Level.DEBUG, msg, null);
         }
     }
 
@@ -533,8 +533,8 @@ public abstract class AbstractLogger imp
      * @param t   A Throwable or null.
      */
     public void debug(Message msg, Throwable t) {
-        if (isEnabled(Level.TRACE, null, msg, t)) {
-            log(null, FQCN, Level.TRACE, msg, t);
+        if (isEnabled(Level.DEBUG, null, msg, t)) {
+            log(null, FQCN, Level.DEBUG, msg, t);
         }
     }
 
@@ -791,7 +791,7 @@ public abstract class AbstractLogger imp
      */
     public void warn(String message, Throwable t) {
         if (isEnabled(Level.WARN, null, message, t)) {
-            log(null, FQCN, Level.DEBUG, new SimpleMessage(message), t);
+            log(null, FQCN, Level.WARN, new SimpleMessage(message), t);
         }
     }
 
@@ -805,7 +805,7 @@ public abstract class AbstractLogger imp
      */
     public void warn(Marker marker, String message, Throwable t) {
         if (isEnabled(Level.WARN, marker, message, t)) {
-            log(marker, FQCN, Level.DEBUG, new SimpleMessage(message), t);
+            log(marker, FQCN, Level.WARN, new SimpleMessage(message), t);
         }
     }
 
@@ -841,7 +841,7 @@ public abstract class AbstractLogger imp
      */
     public void warn(Object message, Throwable t) {
         if (isEnabled(Level.WARN, null, message, t)) {
-            log(null, FQCN, Level.DEBUG, new ObjectMessage(message), t);
+            log(null, FQCN, Level.WARN, new ObjectMessage(message), t);
         }
     }
 
@@ -855,7 +855,7 @@ public abstract class AbstractLogger imp
      */
     public void warn(Marker marker, Object message, Throwable t) {
         if (isEnabled(Level.WARN, marker, message, t)) {
-            log(marker, FQCN, Level.DEBUG, new ObjectMessage(message), t);
+            log(marker, FQCN, Level.WARN, new ObjectMessage(message), t);
         }
     }
 
@@ -1287,7 +1287,7 @@ public abstract class AbstractLogger imp
      *         FATAL, <code>false</code> otherwise.
      */
     public boolean isFatalEnabled() {
-        return isEnabled(Level.ERROR, null, (Object) null, null);
+        return isEnabled(Level.FATAL, null, (Object) null, null);
     }
 
     /**
@@ -1390,48 +1390,10 @@ public abstract class AbstractLogger imp
      * @param level The logging Level to check.
      * @param marker A Marker or null.
      * @param data The message.
-     * @param p1 The first parameter.
-     * @return True if logging is enabled, false otherwise.
-     */
-    protected abstract boolean isEnabled(Level level, Marker marker, String data, Object
p1);
-
-    /**
-     * Determine if logging is enabled.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @return True if logging is enabled, false otherwise.
-     */
-    protected abstract boolean isEnabled(Level level, Marker marker, String data, Object
p1, Object p2);
-
-    /**
-     * Determine if logging is enabled.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @param p3 The third parameter.
-     * @return True if logging is enabled, false otherwise.
-     */
-    protected abstract boolean isEnabled(Level level, Marker marker, String data, Object
p1, Object p2, Object p3);
-
-
-    /**
-     * Determine if logging is enabled.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @param p3 The third parameter.
-     * @param params More message parameters.
+     * @param p1 The parameters.
      * @return True if logging is enabled, false otherwise.
      */
-    protected abstract boolean isEnabled(Level level, Marker marker, String data, Object
p1, Object p2,
-                                         Object p3, Object... params);
+    protected abstract boolean isEnabled(Level level, Marker marker, String data, Object...
p1);
 
     /**
      * Determine if logging is enabled.

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
Wed Sep 26 13:15:54 2012
@@ -87,11 +87,11 @@ public class AbstractLoggerWrapper exten
      * @param level The logging Level to check.
      * @param marker A Marker or null.
      * @param data The message.
-     * @param p1 The first parameter.
+     * @param p1 The parameters.
      * @return true if the event would be logged for the Level, Marker, data and parameter.
      */
     @Override
-    public boolean isEnabled(Level level, Marker marker, String data, Object p1) {
+    public boolean isEnabled(Level level, Marker marker, String data, Object... p1) {
         return logger.isEnabled(level, marker, data, p1);
     }
 
@@ -100,52 +100,6 @@ public class AbstractLoggerWrapper exten
      * @param level The logging Level to check.
      * @param marker A Marker or null.
      * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @return true if the event would be logged for the Level, Marker, data and parameters.
-     */
-    @Override
-    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2)
{
-        return logger.isEnabled(level, marker, data, p1, p2);
-    }
-
-    /**
-     * Detect if the event would be logged.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @param p3 The third parameter.
-     * @return true if the event would be logged for the Level, Marker, data and parameters.
-     */
-    @Override
-    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2,
Object p3) {
-        return logger.isEnabled(level, marker, data, p1, p2, p3);
-    }
-
-    /**
-     * Detect if the event would be logged.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
-     * @param p1 The first parameter.
-     * @param p2 The second parameter.
-     * @param p3 The third parameter.
-     * @param params More message parameters.
-     * @return true if the event would be logged for the Level, Marker, data and parameters.
-     */
-    @Override
-    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2,
Object p3,
-                                Object... params) {
-        return logger.isEnabled(level, marker, data, p2, p2, p3, params);
-    }
-
-    /**
-     * Detect if the event would be logged.
-     * @param level The logging Level to check.
-     * @param marker A Marker or null.
-     * @param data The message.
      * @param t A Throwable.
      * @return true if the event would be logged for the Level, Marker, Object and Throwable,
false otherwise.
      */

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Wed Sep 26 13:15:54 2012
@@ -193,23 +193,7 @@ public final class StatusLogger extends 
     }
 
     @Override
-    protected boolean isEnabled(Level level, Marker marker, String data, Object p1) {
-        return isEnabled(level, marker);
-    }
-
-    @Override
-    protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object
p2) {
-        return isEnabled(level, marker);
-    }
-
-    @Override
-    protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object
p2, Object p3) {
-        return isEnabled(level, marker);
-    }
-
-    @Override
-    protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object
p2, Object p3,
-                                Object... params) {
+    protected boolean isEnabled(Level level, Marker marker, String data, Object... p1) {
         return isEnabled(level, marker);
     }
 

Added: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java?rev=1390458&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
(added)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
Wed Sep 26 13:15:54 2012
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j;
+
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ObjectMessage;
+import org.apache.logging.log4j.message.ParameterizedMessage;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.apache.logging.log4j.spi.AbstractLogger;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class AbstractLoggerTest extends AbstractLogger {
+
+    private static Level currentLevel;
+
+    private LogEvent currentEvent;
+
+    private static Throwable t = new UnsupportedOperationException("Test");
+
+    private static Class obj = AbstractLogger.class;
+
+    private static String pattern = "{}, {}";
+    private static String p1 = "Long Beach";
+    private static String p2 = "California";
+
+    private static Message simple = new SimpleMessage("Hello");
+    private static Message object = new ObjectMessage(obj);
+    private static Message param = new ParameterizedMessage(pattern, p1, p2);
+
+    private static String marker = "TEST";
+
+    private static LogEvent[] events = new LogEvent[] {
+        new LogEvent(null, simple, null),
+        new LogEvent(marker, simple, null),
+        new LogEvent(null, simple, t),
+        new LogEvent(marker, simple, t),
+
+        new LogEvent(null, object, null),
+        new LogEvent(marker, object, null),
+        new LogEvent(null, object, t),
+        new LogEvent(marker, object, t),
+
+        new LogEvent(null, param, null),
+        new LogEvent(marker, param, null),
+
+        new LogEvent(null, simple, null),
+        new LogEvent(null, simple, t),
+        new LogEvent(marker, simple, null),
+        new LogEvent(marker, simple, t),
+
+    };
+
+    @Test
+    public void testTrace() {
+        currentLevel = Level.TRACE;
+
+        currentEvent = events[0];
+        trace("Hello");
+        trace(null, "Hello");
+        currentEvent = events[1];
+        trace(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        trace("Hello", t);
+        trace(null, "Hello", t);
+        currentEvent = events[3];
+        trace(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        trace(obj);
+        currentEvent = events[5];
+        trace(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        trace(obj, t);
+        trace(null, obj, t);
+        currentEvent = events[7];
+        trace(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        trace(pattern, p1, p2);
+        currentEvent = events[9];
+        trace(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        trace(simple);
+        trace(null, simple);
+        trace(null, simple, null);
+        currentEvent = events[11];
+        trace(simple, t);
+        trace(null, simple, t);
+        currentEvent = events[12];
+        trace(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        trace(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Test
+    public void testDebug() {
+        currentLevel = Level.DEBUG;
+
+        currentEvent = events[0];
+        debug("Hello");
+        debug(null, "Hello");
+        currentEvent = events[1];
+        debug(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        debug("Hello", t);
+        debug(null, "Hello", t);
+        currentEvent = events[3];
+        debug(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        debug(obj);
+        currentEvent = events[5];
+        debug(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        debug(obj, t);
+        debug(null, obj, t);
+        currentEvent = events[7];
+        debug(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        debug(pattern, p1, p2);
+        currentEvent = events[9];
+        debug(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        debug(simple);
+        debug(null, simple);
+        debug(null, simple, null);
+        currentEvent = events[11];
+        debug(simple, t);
+        debug(null, simple, t);
+        currentEvent = events[12];
+        debug(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        debug(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Test
+    public void testInfo() {
+        currentLevel = Level.INFO;
+
+        currentEvent = events[0];
+        info("Hello");
+        info(null, "Hello");
+        currentEvent = events[1];
+        info(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        info("Hello", t);
+        info(null, "Hello", t);
+        currentEvent = events[3];
+        info(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        info(obj);
+        currentEvent = events[5];
+        info(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        info(obj, t);
+        info(null, obj, t);
+        currentEvent = events[7];
+        info(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        info(pattern, p1, p2);
+        currentEvent = events[9];
+        info(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        info(simple);
+        info(null, simple);
+        info(null, simple, null);
+        currentEvent = events[11];
+        info(simple, t);
+        info(null, simple, t);
+        currentEvent = events[12];
+        info(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        info(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Test
+    public void testWarn() {
+        currentLevel = Level.WARN;
+
+        currentEvent = events[0];
+        warn("Hello");
+        warn(null, "Hello");
+        currentEvent = events[1];
+        warn(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        warn("Hello", t);
+        warn(null, "Hello", t);
+        currentEvent = events[3];
+        warn(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        warn(obj);
+        currentEvent = events[5];
+        warn(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        warn(obj, t);
+        warn(null, obj, t);
+        currentEvent = events[7];
+        warn(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        warn(pattern, p1, p2);
+        currentEvent = events[9];
+        warn(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        warn(simple);
+        warn(null, simple);
+        warn(null, simple, null);
+        currentEvent = events[11];
+        warn(simple, t);
+        warn(null, simple, t);
+        currentEvent = events[12];
+        warn(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        warn(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Test
+    public void testError() {
+        currentLevel = Level.ERROR;
+
+        currentEvent = events[0];
+        error("Hello");
+        error(null, "Hello");
+        currentEvent = events[1];
+        error(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        error("Hello", t);
+        error(null, "Hello", t);
+        currentEvent = events[3];
+        error(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        error(obj);
+        currentEvent = events[5];
+        error(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        error(obj, t);
+        error(null, obj, t);
+        currentEvent = events[7];
+        error(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        error(pattern, p1, p2);
+        currentEvent = events[9];
+        error(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        error(simple);
+        error(null, simple);
+        error(null, simple, null);
+        currentEvent = events[11];
+        error(simple, t);
+        error(null, simple, t);
+        currentEvent = events[12];
+        error(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        error(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Test
+    public void testFatal() {
+        currentLevel = Level.FATAL;
+
+        currentEvent = events[0];
+        fatal("Hello");
+        fatal(null, "Hello");
+        currentEvent = events[1];
+        fatal(MarkerManager.getMarker("TEST"), "Hello");
+        currentEvent = events[2];
+        fatal("Hello", t);
+        fatal(null, "Hello", t);
+        currentEvent = events[3];
+        fatal(MarkerManager.getMarker("TEST"), "Hello", t);
+        currentEvent = events[4];
+        fatal(obj);
+        currentEvent = events[5];
+        fatal(MarkerManager.getMarker("TEST"), obj);
+        currentEvent = events[6];
+        fatal(obj, t);
+        fatal(null, obj, t);
+        currentEvent = events[7];
+        fatal(MarkerManager.getMarker("TEST"), obj, t);
+        currentEvent = events[8];
+        fatal(pattern, p1, p2);
+        currentEvent = events[9];
+        fatal(MarkerManager.getMarker("TEST"), pattern, p1, p2);
+        currentEvent = events[10];
+        fatal(simple);
+        fatal(null, simple);
+        fatal(null, simple, null);
+        currentEvent = events[11];
+        fatal(simple, t);
+        fatal(null, simple, t);
+        currentEvent = events[12];
+        fatal(MarkerManager.getMarker("TEST"), simple, null);
+        currentEvent = events[13];
+        fatal(MarkerManager.getMarker("TEST"), simple, t);
+    }
+
+    @Override
+    protected void log(Marker marker, String fqcn, Level level, Message data, Throwable t)
{
+        assertTrue("Incorrect Level. Expected " + currentLevel + ", actual " + level, level.equals(currentLevel));
+        if (marker == null) {
+            if (currentEvent.markerName != null) {
+                fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual
is null");
+            }
+        } else {
+            if (currentEvent.markerName == null) {
+                fail("Incorrect marker. Expected null. Actual is " + marker.getName());
+            } else {
+                assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual
" +
+                    marker.getName(), currentEvent.markerName.equals(marker.getName()));
+            }
+        }
+        if (data == null) {
+            if (currentEvent.data != null) {
+                fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
+            }
+        } else {
+            if (currentEvent.data == null) {
+                fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
+            } else {
+                assertTrue("Incorrect message type. Expected " + currentEvent.data + ", actual
" + data,
+                    data.getClass().isAssignableFrom(currentEvent.data.getClass()));
+                assertTrue("Incorrect message. Expected " + currentEvent.data.getFormattedMessage()
+ ", actual " +
+                    data.getFormattedMessage(),
+                    currentEvent.data.getFormattedMessage().equals(data.getFormattedMessage()));
+            }
+        }
+        if (t == null) {
+            if (currentEvent.t != null) {
+                fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
+            }
+        } else {
+            if (currentEvent.t == null) {
+                fail("Incorrect Throwable. Expected null. Actual is " + t);
+            } else {
+                assertTrue("Incorrect Throwable. Expected " + currentEvent.t + ", actual
" + t,
+                    currentEvent.t.equals(t));
+            }
+        }
+    }
+
+    @Override
+    protected boolean isEnabled(Level level, Marker marker, String data) {
+        return isEnabled(level, marker, new SimpleMessage(data), null);
+    }
+
+    @Override
+    protected boolean isEnabled(Level level, Marker marker, String data, Throwable t) {
+        return isEnabled(level, marker, new SimpleMessage(data), t);
+    }
+
+    @Override
+    protected boolean isEnabled(Level level, Marker marker, String data, Object... p1) {
+        return isEnabled(level, marker, new ParameterizedMessage(data, p1), null);
+    }
+
+    @Override
+    protected boolean isEnabled(Level level, Marker marker, Object data, Throwable t) {
+        return isEnabled(level, marker, new ObjectMessage(data), t);
+    }
+
+    @Override
+    protected boolean isEnabled(Level level, Marker marker, Message data, Throwable t) {
+        assertTrue("Incorrect Level. Expected " + currentLevel + ", actual " + level, level.equals(currentLevel));
+        if (marker == null) {
+            if (currentEvent.markerName != null) {
+                fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual
is null");
+            }
+        } else {
+            if (currentEvent.markerName == null) {
+                fail("Incorrect marker. Expected null. Actual is " + marker.getName());
+            } else {
+                assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual
" +
+                    marker.getName(), currentEvent.markerName.equals(marker.getName()));
+            }
+        }
+        if (data == null) {
+            if (currentEvent.data != null) {
+                fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
+            }
+        } else {
+            if (currentEvent.data == null) {
+                fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
+            } else {
+                assertTrue("Incorrect message type. Expected " + currentEvent.data + ", actual
" + data,
+                    data.getClass().isAssignableFrom(currentEvent.data.getClass()));
+                assertTrue("Incorrect message. Expected " + currentEvent.data.getFormattedMessage()
+ ", actual " +
+                    data.getFormattedMessage(),
+                    currentEvent.data.getFormattedMessage().equals(data.getFormattedMessage()));
+            }
+        }
+        if (t == null) {
+            if (currentEvent.t != null) {
+                fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
+            }
+        } else {
+            if (currentEvent.t == null) {
+                fail("Incorrect Throwable. Expected null. Actual is " + t);
+            } else {
+                assertTrue("Incorrect Throwable. Expected " + currentEvent.t + ", actual
" + t,
+                    currentEvent.t.equals(t));
+            }
+        }
+        return true;
+    }
+
+
+    private static class LogEvent {
+
+        String markerName;
+        Message data;
+        Throwable t;
+
+        public LogEvent(String markerName, Message data, Throwable t) {
+            this.markerName = markerName;
+            this.data = data;
+            this.t = t;
+        }
+    }
+}

Modified: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
Wed Sep 26 13:15:54 2012
@@ -67,7 +67,7 @@ public class LoggerTest {
             logger.catching(e);
             assertEquals(1, results.size());
             assertTrue("Incorrect Catching",
-                results.get(0).startsWith(" DEBUG catching java.lang.NullPointerException"));
+                results.get(0).startsWith(" ERROR catching java.lang.NullPointerException"));
         }
     }
 

Modified: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/SimpleLogger.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
Wed Sep 26 13:15:54 2012
@@ -66,12 +66,6 @@ public class SimpleLogger extends Abstra
     }
 
     @Override
-    protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object
p2, Object p3,
-                                Object...params) {
-        return true;
-    }
-
-    @Override
     protected boolean isEnabled(Level level, Marker marker, String msg) {
         return true;
     }
@@ -83,17 +77,7 @@ public class SimpleLogger extends Abstra
     }
 
     @Override
-    protected boolean isEnabled(Level level, Marker marker, String msg, Object p1) {
-        return true;
-    }
-
-    @Override
-    protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object
p2) {
-        return true;
-    }
-
-    @Override
-    protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object
p2, Object p3) {
+    protected boolean isEnabled(Level level, Marker marker, String msg, Object... p1) {
         return true;
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
Wed Sep 26 13:15:54 2012
@@ -127,27 +127,11 @@ public class Logger extends AbstractLogg
     }
 
     @Override
-    public boolean isEnabled(Level level, Marker marker, String msg, Object p1) {
+    public boolean isEnabled(Level level, Marker marker, String msg, Object... p1) {
         return config.filter(level, marker, msg, p1);
     }
 
     @Override
-    public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2)
{
-        return config.filter(level, marker, msg, p1, p2);
-    }
-
-    @Override
-    public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2,
Object p3) {
-        return config.filter(level, marker, msg, p1, p2, p3);
-    }
-
-    @Override
-    public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2,
Object p3,
-                                Object... params) {
-        return config.filter(level, marker, msg, p1, p2, p3, params);
-    }
-
-    @Override
     public boolean isEnabled(Level level, Marker marker, Object msg, Throwable t) {
         return config.filter(level, marker, msg, t);
     }
@@ -319,7 +303,7 @@ public class Logger extends AbstractLogg
             return intLevel >= level.intLevel();
         }
 
-        boolean filter(Level level, Marker marker, String msg, Object p1) {
+        boolean filter(Level level, Marker marker, String msg, Object... p1) {
             config.getConfigurationMonitor().checkConfiguration();
             Filter filter = config.getFilter();
             if (filter != null) {
@@ -332,46 +316,6 @@ public class Logger extends AbstractLogg
             return intLevel >= level.intLevel();
         }
 
-        boolean filter(Level level, Marker marker, String msg, Object p1, Object p2) {
-            config.getConfigurationMonitor().checkConfiguration();
-            Filter filter = config.getFilter();
-            if (filter != null) {
-                Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2);
-                if (r != Filter.Result.NEUTRAL) {
-                    return r == Filter.Result.ACCEPT;
-                }
-            }
-
-            return intLevel >= level.intLevel();
-        }
-
-        boolean filter(Level level, Marker marker, String msg, Object p1, Object p2, Object
p3) {
-            config.getConfigurationMonitor().checkConfiguration();
-            Filter filter = config.getFilter();
-            if (filter != null) {
-                Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2, p3);
-                if (r != Filter.Result.NEUTRAL) {
-                    return r == Filter.Result.ACCEPT;
-                }
-            }
-
-            return intLevel >= level.intLevel();
-        }
-
-        boolean filter(Level level, Marker marker, String msg, Object p1, Object p2, Object
p3,
-                       Object... params) {
-            config.getConfigurationMonitor().checkConfiguration();
-            Filter filter = config.getFilter();
-            if (filter != null) {
-                Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2, p3, params);
-                if (r != Filter.Result.NEUTRAL) {
-                    return r == Filter.Result.ACCEPT;
-                }
-            }
-
-            return intLevel >= level.intLevel();
-        }
-
         boolean filter(Level level, Marker marker, Object msg, Throwable t) {
             config.getConfigurationMonitor().checkConfiguration();
             Filter filter = config.getFilter();

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1390458&r1=1390457&r2=1390458&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed Sep 26 13:15:54 2012
@@ -23,6 +23,10 @@
 
   <body>
     <release version="2.0-beta2" date="TBD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-88" dev="rgoers" type="fix">
+        Many logging methods in AbstractLogger were set to an incorrect logging level. catching
was
+        using the THROWING marker and was set to debug instead of error.
+      </action>
       <action dev="rgoers" type="add">
         Allow the status logging to be directed to stderr or to a file.
       </action>



Mime
View raw message