[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.24-26-g55270dc

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Tue Oct 12 22:28:51 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  55270dc26b29a3c36ae62661bc33f4291ae71b6d (commit)
      from  b8b8a86ea7fb2a8a35751ebbdc0929633c784303 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=55270dc26b29a3c36ae62661bc33f4291ae71b6d
http://github.com/ceki/logback/commit/55270dc26b29a3c36ae62661bc33f4291ae71b6d

commit 55270dc26b29a3c36ae62661bc33f4291ae71b6d
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Oct 12 22:27:28 2010 +0200

    - added logger level change support in LoggerContextListener

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
index 67c7b43..5dcbf7a 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
@@ -184,6 +184,8 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
         child.handleParentLevelChange(effectiveLevelInt);
       }
     }
+    // inform listeners
+    loggerContext.fireOnLevelChange(this, newLevel);
   }
 
   /**
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
index b81c581..c492817 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
@@ -308,6 +308,12 @@ public class LoggerContext extends ContextBase implements ILoggerFactory,
     return new ArrayList<LoggerContextListener>(loggerContextListenerList);
   }
 
+  void fireOnLevelChange(Logger logger, Level level) {
+    for (LoggerContextListener listener : loggerContextListenerList) {
+      listener.onLevelChange(logger, level);
+    }
+  }
+
   private void fireOnReset() {
     for (LoggerContextListener listener : loggerContextListenerList) {
       listener.onReset(this);
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java
index 4bada7e..26edee4 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java
@@ -261,6 +261,10 @@ public class JMXConfigurator extends ContextAwareBase implements
     stop();
   }
 
+  public void onLevelChange(Logger logger, Level level) {
+    // nothing to do
+  }
+
   public void onReset(LoggerContext context) {
     addInfo("onReset() method called JMXActivator [" + objectNameAsString + "]");
   }
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java
index 58fdf48..21fc330 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java
@@ -13,6 +13,8 @@
  */
 package ch.qos.logback.classic.spi;
 
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 
 public interface LoggerContextListener {
@@ -27,4 +29,5 @@ public interface LoggerContextListener {
   public void onStart(LoggerContext context);
   public void onReset(LoggerContext context);
   public void onStop(LoggerContext context);
+  public void onLevelChange(Logger logger, Level level);
 }
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java
index 4e32c1e..5cec4cb 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java
@@ -13,14 +13,18 @@
  */
 package ch.qos.logback.classic.spi;
 
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 
 public class BasicContextListener implements LoggerContextListener {
 
-  enum UpdateType { NONE, START, RESET, STOP};
+  enum UpdateType { NONE, START, RESET, STOP , LEVEL_CHANGE};
   
   UpdateType updateType = UpdateType.NONE;
   LoggerContext context;
+  Logger logger;
+  Level level;
   
   boolean resetResistant;
   
@@ -42,8 +46,15 @@ public class BasicContextListener implements LoggerContextListener {
     updateType =  UpdateType.STOP;;
     this.context = context;
   }
-  
+
   public boolean isResetResistant() {
     return resetResistant;
   }
+
+  public void onLevelChange(Logger logger, Level level) {
+    updateType = UpdateType.LEVEL_CHANGE;
+    this.logger = logger;
+    this.level = level;
+  }
+  
 }
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java
index 95c3186..9d10c90 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java
@@ -15,17 +15,19 @@ package ch.qos.logback.classic.spi;
 
 import static org.junit.Assert.assertEquals;
 
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
 import org.junit.Before;
 import org.junit.Test;
 
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.BasicContextListener.UpdateType;
 
-public class ContextListenerTest  {
-  
+public class ContextListenerTest {
+
   LoggerContext context;
   BasicContextListener listener;
-  
+
   @Before
   public void setUp() throws Exception {
     context = new LoggerContext();
@@ -61,4 +63,21 @@ public class ContextListenerTest  {
     assertEquals(UpdateType.START, listener.updateType);
     assertEquals(listener.context, context);
   }
+
+  void checkLevelChange(String loggerName, Level level) {
+    Logger logger = context.getLogger(loggerName);
+    logger.setLevel(level);
+
+    assertEquals(UpdateType.LEVEL_CHANGE, listener.updateType);
+    assertEquals(listener.logger, logger);
+    assertEquals(listener.level, level);
+
+  }
+
+  @Test
+  public void testLevelChange() {
+    checkLevelChange("a", Level.INFO);
+    checkLevelChange("a.b", Level.ERROR);
+    checkLevelChange("a.b.c", Level.DEBUG);
+  }
 }
diff --git a/logback-site/src/site/pages/manual/encoders.html b/logback-site/src/site/pages/manual/encoders.html
index 237bfd9..70dc3de 100644
--- a/logback-site/src/site/pages/manual/encoders.html
+++ b/logback-site/src/site/pages/manual/encoders.html
@@ -65,12 +65,13 @@
     out.
     </p>
 
-    <p>At present time (2010-03-08), <code>PatternLayotEncoder</code>
-    is the only really useful encoder. It merely wraps a
-    <code>PatternLayout</code> which does most of the work. Thus, may
-    seem that encoders do not bring much to the table except needless
-    complexity. However, we hope that with the advent of new and
-    powerful encoders this impression will change.</p>
+    <p>At the present time (2010-03-08),
+    <code>PatternLayoutEncoder</code> is the only really useful
+    encoder. It merely wraps a <code>PatternLayout</code> which does
+    most of the work. Thus, may seem that encoders do not bring much
+    to the table except needless complexity. However, we hope that
+    with the advent of new and powerful encoders this impression will
+    change.</p>
 
     <h2><a name="interface" href="#interface">Encoder
     interface</a></h2>
@@ -185,6 +186,10 @@ public class LayoutWrappingEncoder&lt;E> extends EncoderBase&lt;E> {
     logback error codes</a>.
     </p>
 
+
+
+     <script src="../templates/footer.js" type="text/javascript"></script>
+
     </div>
   </body>
 </html>

-----------------------------------------------------------------------

Summary of changes:
 .../main/java/ch/qos/logback/classic/Logger.java   |    2 +
 .../java/ch/qos/logback/classic/LoggerContext.java |    6 ++++
 .../qos/logback/classic/jmx/JMXConfigurator.java   |    4 +++
 .../logback/classic/spi/LoggerContextListener.java |    3 ++
 .../logback/classic/spi/BasicContextListener.java  |   15 ++++++++++-
 .../logback/classic/spi/ContextListenerTest.java   |   25 +++++++++++++++++--
 logback-site/src/site/pages/manual/encoders.html   |   17 ++++++++----
 7 files changed, 61 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list