[slf4j-dev] svn commit: r1377 - in slf4j/trunk/log4j-over-slf4j/src: main/java/org/apache/log4j test/java/org/apache/log4j test/java/org/dummy
ceki at slf4j.org
ceki at slf4j.org
Mon Jul 20 16:51:05 CEST 2009
Author: ceki
Date: Mon Jul 20 16:51:05 2009
New Revision: 1377
Added:
slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java
Modified:
slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java
slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java
Log:
Fixed bug 139. See also http://bugzilla.slf4j.org/show_bug.cgi?id=139
Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java Mon Jul 20 16:51:05 2009
@@ -31,7 +31,8 @@
* Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>,
* <code>warn()</code>, <code>error()</code> printing methods are directly
* mapped to their SLF4J equivalents. Log4j's <code>fatal()</code> printing
- * method is mapped to SLF4J's <code>error()</code> method with a FATAL marker.
+ * method is mapped to SLF4J's <code>error()</code> method with a FATAL
+ * marker.
*
* @author Sébastien Pennec
* @author Ceki Gülcü
@@ -147,7 +148,7 @@
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
*
* @param p
- * the priority to check against
+ * the priority to check against
* @return true if this logger is enabled for the given level, false
* otherwise.
*/
@@ -199,7 +200,8 @@
* Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J.
*/
public void debug(Object message) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, null);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
+ message, null);
}
/**
@@ -207,14 +209,16 @@
* SLF4J.
*/
public void debug(Object message, Throwable t) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, t);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
+ message, t);
}
/**
* Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J.
*/
public void info(Object message) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, null);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
+ message, null);
}
/**
@@ -222,14 +226,16 @@
* SLF4J.
*/
public void info(Object message, Throwable t) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, t);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
+ message, t);
}
/**
* Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J.
*/
public void warn(Object message) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, null);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
+ message, null);
}
/**
@@ -237,14 +243,16 @@
* SLF4J.
*/
public void warn(Object message, Throwable t) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, t);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
+ message, t);
}
/**
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
*/
public void error(Object message) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
+ message, null);
}
/**
@@ -252,14 +260,16 @@
* SLF4J.
*/
public void error(Object message, Throwable t) {
- differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
+ differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
+ message, t);
}
/**
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
*/
public void fatal(Object message) {
- differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
+ differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
+ LocationAwareLogger.ERROR_INT, message, null);
}
/**
@@ -267,9 +277,11 @@
* SLF4J. In addition, the call is marked with a marker named "FATAL".
*/
public void fatal(Object message, Throwable t) {
- differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
+ differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
+ LocationAwareLogger.ERROR_INT, message, t);
}
+
public void log(String FQCN, Priority p, Object msg, Throwable t) {
int levelInt = priorityToLevelInt(p);
if (locationAwareLogger != null) {
@@ -280,6 +292,19 @@
}
}
+ public void log(Priority p, Object message, Throwable t) {
+ int levelInt = priorityToLevelInt(p);
+ differentiatedLog(null, CATEGORY_FQCN, levelInt,
+ message, t);
+ }
+
+ public void log(Priority p, Object message) {
+ int levelInt = priorityToLevelInt(p);
+ differentiatedLog(null, CATEGORY_FQCN, levelInt,
+ message, null);
+ }
+
+
private int priorityToLevelInt(Priority p) {
switch (p.level) {
case Level.TRACE_INT:
Modified: slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java Mon Jul 20 16:51:05 2009
@@ -1,3 +1,27 @@
+/*
+ * Copyright (c) 2004-2009 QOS.ch
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
package org.apache.log4j;
import org.apache.log4j.Logger;
Modified: slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java Mon Jul 20 16:51:05 2009
@@ -1,3 +1,27 @@
+/*
+ * Copyright (c) 2004-2009 QOS.ch
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
package org.dummy;
import java.util.logging.Level;
Added: slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java Mon Jul 20 16:51:05 2009
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004-2009 QOS.ch
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package org.dummy;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
+
+public class Bug139 extends TestCase {
+
+ public void test() {
+ ListHandler listHandler = new ListHandler();
+ java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
+ root.addHandler(listHandler);
+ root.setLevel(Level.FINEST);
+ Logger log4jLogger = Logger.getLogger("a");
+ Category log4jCategory = Logger.getLogger("b");
+
+ int n = 0;
+
+ log4jLogger.log(org.apache.log4j.Level.DEBUG, "hello"+(++n));
+ log4jCategory.log(org.apache.log4j.Level.DEBUG, "world"+(++n));
+
+ assertEquals(n, listHandler.list.size());
+
+ for (int i = 0; i < n; i++) {
+ LogRecord logRecord = (LogRecord) listHandler.list.get(i);
+ assertEquals("test", logRecord.getSourceMethodName());
+ }
+ }
+}
More information about the slf4j-dev
mailing list