[logback-dev] svn commit: r2054 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic test/java/ch/qos/logback/classic
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Thu Dec 4 18:16:01 CET 2008
Author: ceki
Date: Thu Dec 4 18:16:01 2008
New Revision: 2054
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
Log:
Fixes LBCLASSIC-90. Logger reset set logger levels to NULL, except for the root logger which gets set to DEBUG.
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Thu Dec 4 18:16:01 2008
@@ -320,8 +320,18 @@
return childLogger;
}
+ private void localLevelReset() {
+ effectiveLevelInt = DEBUG_INT;
+ if(isRootLogger()) {
+ level = Level.DEBUG;
+ } else {
+ level = null;
+ }
+ }
+
void recursiveReset() {
detachAndStopAllAppenders();
+ localLevelReset();
additive = true;
if (childrenList == null) {
return;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java Thu Dec 4 18:16:01 2008
@@ -200,6 +200,7 @@
resetStatusListeners();
}
+
private void resetStatusListeners() {
StatusManager sm = getStatusManager();
for (StatusListener sl : sm.getCopyOfStatusListenerList()) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java Thu Dec 4 18:16:01 2008
@@ -152,4 +152,24 @@
sm.getCount() == 1);
}
+
+ @Test
+ public void resetTest() {
+
+ Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger a = lc.getLogger("a");
+ Logger ab = lc.getLogger("a.b");
+
+ ab.setLevel(Level.WARN);
+ root.setLevel(Level.INFO);
+ lc.reset();
+ assertEquals(Level.DEBUG, root.getEffectiveLevel());
+ assertEquals(Level.DEBUG, a.getEffectiveLevel());
+ assertEquals(Level.DEBUG, ab.getEffectiveLevel());
+
+ assertEquals(Level.DEBUG, root.getLevel());
+ assertNull(a.getLevel());
+ assertNull(ab.getLevel());
+
+ }
}
\ No newline at end of file
More information about the logback-dev
mailing list