362111 - StdErrLog.isDebugEnabled() returns true too often

This commit is contained in:
Joakim Erdfelt 2011-10-26 10:34:33 -07:00
parent fe7359c68c
commit 064c93c53b
2 changed files with 20 additions and 4 deletions

View File

@ -312,7 +312,7 @@ public class StdErrLog implements Logger
public boolean isDebugEnabled() public boolean isDebugEnabled()
{ {
return (_level >= LEVEL_DEBUG); return (_level <= LEVEL_DEBUG);
} }
/** /**

View File

@ -243,8 +243,6 @@ public class StdErrLogTest
log.setLevel(StdErrLog.LEVEL_DEBUG); log.setLevel(StdErrLog.LEVEL_DEBUG);
log.debug("my hovercraft is"); log.debug("my hovercraft is");
Assert.assertThat("log should report as debug enabled", log.isDebugEnabled(), is(true));
// Level All // Level All
log.setLevel(StdErrLog.LEVEL_ALL); log.setLevel(StdErrLog.LEVEL_ALL);
log.debug("full of eels."); log.debug("full of eels.");
@ -283,7 +281,7 @@ public class StdErrLogTest
// Show Ignored // Show Ignored
log.setLevel(StdErrLog.LEVEL_ALL); log.setLevel(StdErrLog.LEVEL_ALL);
log.ignore(new Throwable("Don't ignore me")); log.ignore(new Throwable("Don't ignore me"));
// Set to Debug level // Set to Debug level
log.setLevel(StdErrLog.LEVEL_DEBUG); log.setLevel(StdErrLog.LEVEL_DEBUG);
log.ignore(new Throwable("Debug me")); log.ignore(new Throwable("Debug me"));
@ -295,4 +293,22 @@ public class StdErrLogTest
Assert.assertThat(output,containsString("Don't ignore me")); Assert.assertThat(output,containsString("Don't ignore me"));
Assert.assertThat(output,not(containsString("Debug 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));
}
} }