fix bug 234
diff --git a/integration/src/test/java/org/slf4j/IncompatibleMultiBindingAssertionTest.java b/integration/src/test/java/org/slf4j/IncompatibleMultiBindingAssertionTest.java
new file mode 100644
index 0000000..455da4b
--- /dev/null
+++ b/integration/src/test/java/org/slf4j/IncompatibleMultiBindingAssertionTest.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2004-2011 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.slf4j;
+
+import java.io.PrintStream;
+import java.util.List;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+public class IncompatibleMultiBindingAssertionTest extends TestCase {
+
+ StringPrintStream sps = new StringPrintStream(System.err);
+ PrintStream old = System.err;
+ int diff = 1024 + new Random().nextInt(10000);
+
+ public IncompatibleMultiBindingAssertionTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ System.setErr(sps);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ System.setErr(old);
+ }
+
+ public void test() throws Exception {
+ try {
+ Logger logger = LoggerFactory.getLogger(this.getClass());
+ String msg = "hello world " + diff;
+ logger.info(msg);
+ fail("was expecting NoSuchMethodError");
+ } catch (NoSuchMethodError e) {
+ }
+ List list = sps.stringList;
+ assertMsgContains(list, 0, "Class path contains multiple SLF4J bindings.");
+ assertMsgContains(list, 1, "Found binding in");
+ assertMsgContains(list, 2, "Found binding in");
+ assertMsgContains(list, 3, "See http://www.slf4j.org/codes.html");
+ assertMsgContains(list, 4,
+ "slf4j-api 1.6.x (or later) is incompatible with this binding");
+ assertMsgContains(list, 5, "Your binding is version 1.5.5 or earlier.");
+
+ }
+
+ void assertMsgContains(List strList, int index, String msg) {
+ assertTrue(((String) strList.get(index)).contains(msg));
+ }
+}
diff --git a/slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java b/slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java
index d776c1f..c1aeaff 100644
--- a/slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java
+++ b/slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java
@@ -163,7 +163,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void trace(Marker marker, String msg) {
- if (!logger.isTraceEnabled())
+ if (!logger.isTraceEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -177,7 +177,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void trace(Marker marker, String format, Object arg) {
- if (!logger.isTraceEnabled())
+ if (!logger.isTraceEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg)
@@ -194,7 +194,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void trace(Marker marker, String format, Object arg1, Object arg2) {
- if (!logger.isTraceEnabled())
+ if (!logger.isTraceEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg1, arg2)
@@ -211,7 +211,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void trace(Marker marker, String format, Object[] argArray) {
- if (!logger.isTraceEnabled())
+ if (!logger.isTraceEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.arrayFormat(format, argArray)
@@ -227,7 +227,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void trace(Marker marker, String msg, Throwable t) {
- if (!logger.isTraceEnabled())
+ if (!logger.isTraceEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -338,7 +338,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void debug(Marker marker, String msg) {
- if (!logger.isDebugEnabled())
+ if (!logger.isDebugEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -352,7 +352,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void debug(Marker marker, String format, Object arg) {
- if (!logger.isDebugEnabled())
+ if (!logger.isDebugEnabled(marker))
return;
if (instanceofLAL) {
FormattingTuple ft = MessageFormatter.format(format, arg);
@@ -368,7 +368,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void debug(Marker marker, String format, Object arg1, Object arg2) {
- if (!logger.isDebugEnabled())
+ if (!logger.isDebugEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg1, arg2)
@@ -385,7 +385,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void debug(Marker marker, String format, Object[] argArray) {
- if (!logger.isDebugEnabled())
+ if (!logger.isDebugEnabled(marker))
return;
if (instanceofLAL) {
@@ -402,7 +402,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void debug(Marker marker, String msg, Throwable t) {
- if (!logger.isDebugEnabled())
+ if (!logger.isDebugEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -513,7 +513,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void info(Marker marker, String msg) {
- if (!logger.isInfoEnabled())
+ if (!logger.isInfoEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -527,7 +527,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void info(Marker marker, String format, Object arg) {
- if (!logger.isInfoEnabled())
+ if (!logger.isInfoEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg)
@@ -544,7 +544,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void info(Marker marker, String format, Object arg1, Object arg2) {
- if (!logger.isInfoEnabled())
+ if (!logger.isInfoEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg1, arg2)
@@ -561,7 +561,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void info(Marker marker, String format, Object[] argArray) {
- if (!logger.isInfoEnabled())
+ if (!logger.isInfoEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.arrayFormat(format, argArray)
@@ -577,7 +577,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void info(Marker marker, String msg, Throwable t) {
- if (!logger.isInfoEnabled())
+ if (!logger.isInfoEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -685,7 +685,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void warn(Marker marker, String msg) {
- if (!logger.isWarnEnabled())
+ if (!logger.isWarnEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -699,7 +699,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void warn(Marker marker, String format, Object arg) {
- if (!logger.isWarnEnabled())
+ if (!logger.isWarnEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg)
@@ -716,7 +716,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void warn(Marker marker, String format, Object arg1, Object arg2) {
- if (!logger.isWarnEnabled())
+ if (!logger.isWarnEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg1, arg2)
@@ -733,7 +733,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void warn(Marker marker, String format, Object[] argArray) {
- if (!logger.isWarnEnabled())
+ if (!logger.isWarnEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.arrayFormat(format, argArray)
@@ -749,7 +749,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void warn(Marker marker, String msg, Throwable t) {
- if (!logger.isWarnEnabled())
+ if (!logger.isWarnEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -860,7 +860,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void error(Marker marker, String msg) {
- if (!logger.isErrorEnabled())
+ if (!logger.isErrorEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,
@@ -874,7 +874,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void error(Marker marker, String format, Object arg) {
- if (!logger.isErrorEnabled())
+ if (!logger.isErrorEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg)
@@ -891,7 +891,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void error(Marker marker, String format, Object arg1, Object arg2) {
- if (!logger.isErrorEnabled())
+ if (!logger.isErrorEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.format(format, arg1, arg2)
@@ -908,7 +908,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void error(Marker marker, String format, Object[] argArray) {
- if (!logger.isErrorEnabled())
+ if (!logger.isErrorEnabled(marker))
return;
if (instanceofLAL) {
String formattedMessage = MessageFormatter.arrayFormat(format, argArray)
@@ -924,7 +924,7 @@
* Delegate to the appropriate method of the underlying logger.
*/
public void error(Marker marker, String msg, Throwable t) {
- if (!logger.isErrorEnabled())
+ if (!logger.isErrorEnabled(marker))
return;
if (instanceofLAL) {
((LocationAwareLogger) logger).log(marker, fqcn,