[logback-dev] svn commit: r1503 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic logback-classic/src/main/java/ch/qos/logback/classic/turbo logback-classic/src/test/java/ch/qos/logback/classic logback-site/src/site/pages logback-site/src/site/pages/manual

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Apr 2 20:51:38 CEST 2007


Author: ceki
Date: Mon Apr  2 20:51:38 2007
New Revision: 1503

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/turbo/MarkerFilter.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java
   logback/trunk/logback-site/src/site/pages/manual/joran.html
   logback/trunk/logback-site/src/site/pages/news.html

Log:

- Contrary to previous versions of logback, the various
  Logger.isXYZEnabled(Marker) methods now take into account the marker
  information passed as parameter.

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	Mon Apr  2 20:51:38 2007
@@ -567,22 +567,12 @@
     filterAndLog(FQCN, marker, Level.INFO, msg, null, t);
   }
 
-  public final boolean isDebugEnabled(Marker o1, String o2, Object o3,
-      Throwable o4, Object o5) {
-    final FilterReply decision = callTurboFilters(Level.DEBUG);
-    if (decision == FilterReply.NEUTRAL) {
-      return effectiveLevelInt <= Level.DEBUG_INT;
-    } else if (decision == FilterReply.DENY) {
-      return false;
-    } else if (decision == FilterReply.ACCEPT) {
-      return true;
-    } else {
-      throw new IllegalStateException("Unknown FilterReply value: " + decision);
-    }
+  public final boolean isDebugEnabled() {
+    return isDebugEnabled(null);
   }
 
-  public final boolean isDebugEnabled() {
-    final FilterReply decision = callTurboFilters(Level.DEBUG);
+  public boolean isDebugEnabled(Marker marker) {
+    final FilterReply decision = callTurboFilters(marker, Level.DEBUG);
     if (decision == FilterReply.NEUTRAL) {
       return effectiveLevelInt <= Level.DEBUG_INT;
     } else if (decision == FilterReply.DENY) {
@@ -592,16 +582,17 @@
     } else {
       throw new IllegalStateException("Unknown FilterReply value: " + decision);
     }
+   
   }
 
-  public boolean isDebugEnabled(Marker marker) {
-    return isDebugEnabled();
+  public final boolean isErrorEnabled() {
+    return isErrorEnabled(null);
   }
 
-  public final boolean isErrorEnabled() {
-    FilterReply decision = callTurboFilters(Level.ERROR);
+  public boolean isErrorEnabled(Marker marker) {
+    FilterReply decision = callTurboFilters(marker, Level.ERROR);
     if (decision == FilterReply.NEUTRAL) {
-      return effectiveLevelInt <= Level.DEBUG_INT;
+      return effectiveLevelInt <= Level.ERROR_INT;
     } else if (decision == FilterReply.DENY) {
       return false;
     } else if (decision == FilterReply.ACCEPT) {
@@ -611,14 +602,14 @@
     }
   }
 
-  public boolean isErrorEnabled(Marker marker) {
-    return isErrorEnabled();
+  public boolean isInfoEnabled() {
+    return isInfoEnabled(null);
   }
 
-  public boolean isInfoEnabled() {
-    FilterReply decision = callTurboFilters(Level.INFO);
+  public boolean isInfoEnabled(Marker marker) {
+    FilterReply decision = callTurboFilters(marker, Level.INFO);
     if (decision == FilterReply.NEUTRAL) {
-      return effectiveLevelInt <= Level.DEBUG_INT;
+      return effectiveLevelInt <= Level.INFO_INT;
     } else if (decision == FilterReply.DENY) {
       return false;
     } else if (decision == FilterReply.ACCEPT) {
@@ -628,14 +619,14 @@
     }
   }
 
-  public boolean isInfoEnabled(Marker marker) {
-    return isInfoEnabled();
+  public boolean isWarnEnabled() {
+    return isWarnEnabled(null);
   }
 
-  public boolean isWarnEnabled() {
-    FilterReply decision = callTurboFilters(Level.WARN);
+  public boolean isWarnEnabled(Marker marker) {
+    FilterReply decision = callTurboFilters(marker, Level.WARN);
     if (decision == FilterReply.NEUTRAL) {
-      return effectiveLevelInt <= Level.DEBUG_INT;
+      return effectiveLevelInt <= Level.WARN_INT;
     } else if (decision == FilterReply.DENY) {
       return false;
     } else if (decision == FilterReply.ACCEPT) {
@@ -643,16 +634,13 @@
     } else {
       throw new IllegalStateException("Unknown FilterReply value: " + decision);
     }
+    
   }
-
-  public boolean isWarnEnabled(Marker marker) {
-    return isWarnEnabled();
-  }
-
-  public boolean isEnabledFor(Level level) {
-    FilterReply decision = callTurboFilters(level);
+  
+  public boolean isEnabledFor(Marker marker, Level level) {
+    FilterReply decision = callTurboFilters(marker, level);
     if (decision == FilterReply.NEUTRAL) {
-      return effectiveLevelInt <= Level.DEBUG_INT;
+      return effectiveLevelInt <= level.levelInt;
     } else if (decision == FilterReply.DENY) {
       return false;
     } else if (decision == FilterReply.ACCEPT) {
@@ -661,6 +649,10 @@
       throw new IllegalStateException("Unknown FilterReply value: " + decision);
     }
   }
+  
+  public boolean isEnabledFor(Level level) {
+    return isEnabledFor(null, level);
+  }
 
   public void warn(String msg) {
     filterAndLog(FQCN, null, Level.WARN, msg, null, null);
@@ -725,8 +717,8 @@
    * @param level
    * @return the reply given by the TurboFilters
    */
-  private FilterReply callTurboFilters(Level level) {
-    return loggerContext.getTurboFilterChainDecision(null, this, level, null,
+  private FilterReply callTurboFilters(Marker marker, Level level) {
+    return loggerContext.getTurboFilterChainDecision(marker, this, level, null,
         null, null);
   }
 

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java	Mon Apr  2 20:51:38 2007
@@ -8,7 +8,8 @@
 import ch.qos.logback.core.spi.FilterReply;
 
 /**
- * Checks whether the marker in the event matches the marker specified by the user as a property.
+ * Checks whether the marker in the event matches the marker specified by the 
+ * user.
  */
 public class MarkerFilter extends MatchingFilter {
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	Mon Apr  2 20:51:38 2007
@@ -82,14 +82,27 @@
     logger.error("x");
     assertEquals(3, listAppender.list.size());
   }
+
+  public void testEnabledX_All() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.ALL);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+    assertTrue(logger.isDebugEnabled());
+    assertTrue(logger.isInfoEnabled());
+    assertTrue(logger.isWarnEnabled());
+    assertTrue(logger.isErrorEnabled());
+    assertTrue(logger.isEnabledFor(Level.DEBUG));
+    assertTrue(logger.isEnabledFor(Level.INFO));
+    assertTrue(logger.isEnabledFor(Level.WARN));    
+    assertTrue(logger.isEnabledFor(Level.ERROR));
+  }
   
   public void testEnabledX_Debug() throws Exception {
     LoggerContext lc = new LoggerContext();
     Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
     root.setLevel(Level.DEBUG);
     Logger logger = lc.getLogger(BasicLoggerTest.class);
-
-
     assertTrue(logger.isDebugEnabled());
     assertTrue(logger.isInfoEnabled());
     assertTrue(logger.isWarnEnabled());
@@ -107,7 +120,6 @@
     Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
     root.setLevel(Level.INFO);
     Logger logger = lc.getLogger(BasicLoggerTest.class);
-
     assertFalse(logger.isDebugEnabled());
     assertTrue(logger.isInfoEnabled());
     assertTrue(logger.isWarnEnabled());
@@ -123,7 +135,6 @@
     Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
     root.setLevel(Level.WARN);
     Logger logger = lc.getLogger(BasicLoggerTest.class);
-
     assertFalse(logger.isDebugEnabled());
     assertFalse(logger.isInfoEnabled());
     assertTrue(logger.isWarnEnabled());
@@ -139,7 +150,6 @@
     Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
     root.setLevel(Level.ERROR);
     Logger logger = lc.getLogger(BasicLoggerTest.class);
-
     assertFalse(logger.isDebugEnabled());
     assertFalse(logger.isInfoEnabled());
     assertFalse(logger.isWarnEnabled());
@@ -150,5 +160,18 @@
     assertTrue(logger.isEnabledFor(Level.ERROR));
   }
 
-  
+  public void testEnabledX_Off() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.OFF);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+    assertFalse(logger.isDebugEnabled());
+    assertFalse(logger.isInfoEnabled());
+    assertFalse(logger.isWarnEnabled());
+    assertFalse(logger.isErrorEnabled());
+    assertFalse(logger.isEnabledFor(Level.DEBUG));
+    assertFalse(logger.isEnabledFor(Level.INFO));
+    assertFalse(logger.isEnabledFor(Level.WARN));    
+    assertFalse(logger.isEnabledFor(Level.ERROR));
+  }
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java	Mon Apr  2 20:51:38 2007
@@ -1,16 +1,20 @@
 package ch.qos.logback.classic;
 
 import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
 
+import ch.qos.logback.classic.turbo.MarkerFilter;
 import ch.qos.logback.classic.turbo.TurboFilter;
 import ch.qos.logback.core.spi.FilterReply;
 import junit.framework.TestCase;
 
 public class TurboFilteringInLoggerTest extends TestCase {
 
+  static final String BLUE = "BLUE";
   LoggerContext context;
   Logger logger;
-
+  Marker blueMarker = MarkerFactory.getMarker(BLUE);
+  
   @Override
   protected void setUp() throws Exception {
     super.setUp();
@@ -30,12 +34,30 @@
     filter.start();
     context.addTurboFilter(filter);
   }
-  
+
   private void addNoFilter() {
     NoFilter filter = new NoFilter();
     filter.start();
     context.addTurboFilter(filter);
   }
+  
+  private void addAcceptBLUEFilter() {
+    MarkerFilter filter = new MarkerFilter();
+    filter.setMarker(BLUE);
+    filter.setOnMatch("ACCEPT");
+    filter.start();
+    context.addTurboFilter(filter);
+  }
+  
+  private void addDenyBLUEFilter() {
+    MarkerFilter filter = new MarkerFilter();
+    filter.setMarker(BLUE);
+    filter.setOnMatch("DENY");
+    filter.start();
+    context.addTurboFilter(filter);
+  }
+  
+  
 
   public void testIsDebugEnabledWithYesFilter() {
     addYesFilter();
@@ -66,37 +88,50 @@
     logger.setLevel(Level.ERROR);
     assertTrue(logger.isEnabledFor(Level.INFO));
   }
-  
+
   public void testIsEnabledForWithNoFilter() {
     addNoFilter();
     logger.setLevel(Level.DEBUG);
     assertFalse(logger.isEnabledFor(Level.INFO));
   }
-  
+
   public void testIsDebugEnabledWithNoFilter() {
     addNoFilter();
     logger.setLevel(Level.DEBUG);
     assertFalse(logger.isDebugEnabled());
   }
-  
+
   public void testIsInfoEnabledWithNoFilter() {
     addNoFilter();
     logger.setLevel(Level.DEBUG);
     assertFalse(logger.isInfoEnabled());
   }
-  
+
   public void testIsWarnEnabledWithNoFilter() {
     addNoFilter();
     logger.setLevel(Level.DEBUG);
     assertFalse(logger.isWarnEnabled());
   }
-  
+
   public void testIsErrorEnabledWithNoFilter() {
     addNoFilter();
     logger.setLevel(Level.DEBUG);
     assertFalse(logger.isErrorEnabled());
   }
 
+  public void testIsErrorEnabledWithAcceptBlueFilter() {
+    addAcceptBLUEFilter();
+    logger.setLevel(Level.ERROR);
+    assertTrue(logger.isDebugEnabled(blueMarker));
+  }
+
+  public void testIsErrorEnabledWithDenyBlueFilter() {
+    addDenyBLUEFilter();
+    logger.setLevel(Level.ALL);
+    assertFalse(logger.isDebugEnabled(blueMarker));
+  }
+
+  
 }
 
 class YesFilter extends TurboFilter {

Modified: logback/trunk/logback-site/src/site/pages/manual/joran.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/manual/joran.html	(original)
+++ logback/trunk/logback-site/src/site/pages/manual/joran.html	Mon Apr  2 20:51:38 2007
@@ -50,26 +50,37 @@
     continent's largest sweet water reserve.
     </p>
 
-    <p>In the first part, this document presents Joran's use as a
-    using Joran in order to configure logback. In the second, <a
-    href="#Joran">a second part</a> gives a generic explanation of how
-    the configuration framework in logback works, and how to use it in
-    your own applications.
-</p>
+    <p>In the first part, we start by presenting ways for configuring
+    logback, with many example configuration scripts.  In the <a
+    href="#Joran"> second part</a>, we present Joran as a generic
+    configuration framework, and how you can use it to configure your
+    own applications.
+    </p>
 
-<h2>Configuration in logback</h2>
+    <h2>Configuration in logback</h2>
 
-<p>
-Logback can be configured both programmatically and with an xml configuration
-file. Here are the steps that logback follows to try to configure itself:
-</p>
+    <p>Logback can be configured both programmatically or with
+    configuration script (in XML formal). Here are the steps that
+    logback follows to try to configure itself:
+    </p>
 
-<ul>
-	<p>Logback tries to find a file called <em>logback.xml</em> within the classpath.</p>
-	<p>If no such file is found, it checks for another file called <em>logback-test.xml</em>.</p>
-	<p>In case none of these files are found, logback configures itself automatically using the 
-	<a href="../xref/ch/qos/logback/classic/BasicConfigurator.html"><code>BasicConfigurator</code>
-	</a> class.</p>
+    xxxxxxxxxxxxx
+
+    <ul>
+      <li>
+        <p>Logback tries to find a file called <em>logback.xml</em>
+        within the classpath.</p>
+      </li>
+
+      <li><p>If no such file is found, it checks for another file
+      called <em>logback-test.xml</em>.</p>
+      </li>
+      
+      <li><p>In case none of these files are found, logback configures
+      itself automatically using the <a
+      href="../xref/ch/qos/logback/classic/BasicConfigurator.html"><code>BasicConfigurator</code>
+      </a> class.</p>
+      </li>
 </ul>
 <p>
 The first two checks allow for two environments to cooperate nicely. When the application

Modified: logback/trunk/logback-site/src/site/pages/news.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/news.html	(original)
+++ logback/trunk/logback-site/src/site/pages/news.html	Mon Apr  2 20:51:38 2007
@@ -28,52 +28,66 @@
 
   <hr width="80%" align="center" />
   
-    <h3>March 29th, 2007 - Release of version 0.9.4</h3>
+  <h3>April 2nd, 2007 - Release of version 0.9.5</h3>
+
+  <p>Fixed methods <code>isInfoEnabled</code>,
+  <code>isWarnEnabled</code> and <code>isErrorEnabled</code> methods
+  in <code>ch.qos.logback.classic.Logger</code> class which failed to
+  work correctly. This bug was reported today by Pavel Kral on the
+  slf4j-user list. 
+  </p>
+
+  <p>Contrary to previous versions of logback, the various
+  Logger.isXYZEnabled(Marker) methods now take into account the marker
+  information passed as parameter.
+  </p>
+
+
+  <hr width="80%" align="center" />
+  
+  <h3>March 29th, 2007 - Release of version 0.9.4</h3>
     
-    <p>Significant bug fixes made to
-    <code>c.q.l.access.TeeFilter</code> and Co. Images and other
-    binary files are now intercepted and replayed correctly. As for
-    "x-www-form-urlencoded" post requests, their input buffer is left
-    untouched. In a best-effort attempt, the input buffer for
-    "x-www-form-urlencoded" post requests is later reconstructed
-    through the request parameters. However, it may differ from the
-    original buffer.
-    </p>
+  <p>Significant bug fixes made to <code>c.q.l.access.TeeFilter</code>
+  and Co. Images and other binary files are now intercepted and
+  replayed correctly. As for "x-www-form-urlencoded" post requests,
+  their input buffer is left untouched. In a best-effort attempt, the
+  input buffer for "x-www-form-urlencoded" post requests is later
+  reconstructed through the request parameters. However, it may differ
+  from the original buffer.
+  </p>
     
-    <p>
-     The logback team released today the first version of a plugin for Eclipse that
-     allows developpers to see the logs generated by a running application. 
-     It offers several great features, check the 
-     <a href="consolePlugin.html">user guide</a> for more information.
-    </p>
+  <p>The logback team released today the first version of a plugin for
+  Eclipse that allows developpers to visualize logs generated by a
+  running application.  It offers several nice features. Please check
+  the <a href="consolePlugin.html">console plugin-in guide</a> for
+  more details.
+  </p>
 
-    <h3>March 20th, 2007 - Release of version 0.9.3</h3>
-    
-    <p>Includes in configuration files are now supported by Joran,
-     logback's configuration framework. A file can contain an
-     <em>include</em> element that has a <em>file</em> or <em>url</em>
-     attribute pointing to a configuration file.  See the <a
-     href="manual/joran.html#Include">chapter about configuration</a>
-     in the logback's online manual for more information.
-    </p>
+  <h3>March 20th, 2007 - Release of version 0.9.3</h3>
+  
+  <p>Includes in configuration files are now supported by Joran,
+  logback's configuration framework. A file can contain an
+  <em>include</em> element that has a <em>file</em> or <em>url</em>
+  attribute pointing to a configuration file.  See the <a
+  href="manual/joran.html#Include">chapter about configuration</a>
+  in the logback's online manual for more information.
+  </p>
     
-    <p>
-     Corrected bug 53 reported by Wilkins Poe. There is now a 
-     <a href="dependencies.html">dependencies
-     page</a> that shows the requirements of each of logback's modules.
-    </p>
+  <p>Corrected bug 53 reported by Wilkins Poe. There is now a <a
+  href="dependencies.html">dependencies page</a> that shows the
+  requirements of each of logback's modules.
+  </p>
     
-    <p>
-     After a <a href="http://www.slf4j.org/pipermail/user/2007-March/000297.html">
-     discussion on the SLF4J mailing list</a> started by Franck Routier, a correction has been 
-     made when logging using the <em>JCL104-over-slf4j</em>
-     module. Logback now correctly shows the caller location information.
-    </p>
+  <p>After a <a
+  href="http://www.slf4j.org/pipermail/user/2007-March/000297.html">
+  discussion on the SLF4J mailing list</a> started by Franck Routier,
+  a correction has been made when logging using the
+  <em>JCL104-over-slf4j</em> module. Logback now correctly shows the
+  caller location information.
+  </p>
     
-    <p>
-     As with most of the logback releases, the documentation has been improved
-     in many aspects.
-    </p>
+  <p>As in most logback releases, the documentation has been improved.
+  </p>
     
 
     <h3>March 5th, 2007 - Release of version 0.9.2</h3>



More information about the logback-dev mailing list