Skip to content

Commit

Permalink
fix bug 234
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Jun 11, 2012
1 parent 2888876 commit 3e24a5c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 25 deletions.
@@ -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));
}
}
50 changes: 25 additions & 25 deletions slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java
Expand Up @@ -163,7 +163,7 @@ public void trace(String msg, Throwable t) {
* 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,
Expand All @@ -177,7 +177,7 @@ public void trace(Marker marker, String msg) {
* 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)
Expand All @@ -194,7 +194,7 @@ public void trace(Marker marker, String format, Object arg) {
* 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)
Expand All @@ -211,7 +211,7 @@ public void trace(Marker marker, String format, Object arg1, Object arg2) {
* 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)
Expand All @@ -227,7 +227,7 @@ public void trace(Marker marker, String format, Object[] argArray) {
* 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,
Expand Down Expand Up @@ -338,7 +338,7 @@ public void debug(String msg, Throwable t) {
* 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,
Expand All @@ -352,7 +352,7 @@ public void debug(Marker marker, String msg) {
* 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);
Expand All @@ -368,7 +368,7 @@ public void debug(Marker marker, String format, Object arg) {
* 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)
Expand All @@ -385,7 +385,7 @@ public void debug(Marker marker, String format, Object arg1, Object arg2) {
* 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) {

Expand All @@ -402,7 +402,7 @@ public void debug(Marker marker, String format, Object[] argArray) {
* 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,
Expand Down Expand Up @@ -513,7 +513,7 @@ public void info(String msg, Throwable t) {
* 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,
Expand All @@ -527,7 +527,7 @@ public void info(Marker marker, String msg) {
* 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)
Expand All @@ -544,7 +544,7 @@ public void info(Marker marker, String format, Object arg) {
* 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)
Expand All @@ -561,7 +561,7 @@ public void info(Marker marker, String format, Object arg1, Object arg2) {
* 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)
Expand All @@ -577,7 +577,7 @@ public void info(Marker marker, String format, Object[] argArray) {
* 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,
Expand Down Expand Up @@ -685,7 +685,7 @@ public void warn(String msg, Throwable t) {
* 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,
Expand All @@ -699,7 +699,7 @@ public void warn(Marker marker, String msg) {
* 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)
Expand All @@ -716,7 +716,7 @@ public void warn(Marker marker, String format, Object arg) {
* 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)
Expand All @@ -733,7 +733,7 @@ public void warn(Marker marker, String format, Object arg1, Object arg2) {
* 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)
Expand All @@ -749,7 +749,7 @@ public void warn(Marker marker, String format, Object[] argArray) {
* 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,
Expand Down Expand Up @@ -860,7 +860,7 @@ public void error(String msg, Throwable t) {
* 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,
Expand All @@ -874,7 +874,7 @@ public void error(Marker marker, String msg) {
* 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)
Expand All @@ -891,7 +891,7 @@ public void error(Marker marker, String format, Object arg) {
* 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)
Expand All @@ -908,7 +908,7 @@ public void error(Marker marker, String format, Object arg1, Object arg2) {
* 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)
Expand All @@ -924,7 +924,7 @@ public void error(Marker marker, String format, Object[] argArray) {
* 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,
Expand Down

0 comments on commit 3e24a5c

Please sign in to comment.