diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java index d2457c10f25..d0c6bdee1b9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java @@ -312,7 +312,7 @@ public class StdErrLog implements Logger public boolean isDebugEnabled() { - return (_level >= LEVEL_DEBUG); + return (_level <= LEVEL_DEBUG); } /** diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java index 29a87551f71..bc6899588b5 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java @@ -243,8 +243,6 @@ public class StdErrLogTest log.setLevel(StdErrLog.LEVEL_DEBUG); log.debug("my hovercraft is"); - Assert.assertThat("log should report as debug enabled", log.isDebugEnabled(), is(true)); - // Level All log.setLevel(StdErrLog.LEVEL_ALL); log.debug("full of eels."); @@ -283,7 +281,7 @@ public class StdErrLogTest // Show Ignored log.setLevel(StdErrLog.LEVEL_ALL); log.ignore(new Throwable("Don't ignore me")); - + // Set to Debug level log.setLevel(StdErrLog.LEVEL_DEBUG); log.ignore(new Throwable("Debug me")); @@ -295,4 +293,22 @@ public class StdErrLogTest Assert.assertThat(output,containsString("Don't ignore me")); Assert.assertThat(output,not(containsString("Debug me"))); } + + @Test + public void testIsDebugEnabled() { + StdErrLog log = new StdErrLog(StdErrLogTest.class.getName()); + log.setHideStacks(true); + + log.setLevel(StdErrLog.LEVEL_ALL); + Assert.assertThat("log.level(all).isDebugEnabled", log.isDebugEnabled(), is(true)); + + log.setLevel(StdErrLog.LEVEL_DEBUG); + Assert.assertThat("log.level(debug).isDebugEnabled", log.isDebugEnabled(), is(true)); + + log.setLevel(StdErrLog.LEVEL_INFO); + Assert.assertThat("log.level(info).isDebugEnabled", log.isDebugEnabled(), is(false)); + + log.setLevel(StdErrLog.LEVEL_WARN); + Assert.assertThat("log.level(warn).isDebugEnabled", log.isDebugEnabled(), is(false)); + } }