[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.28-10-g4373dfa

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Thu Feb 10 13:15:07 CET 2011


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  4373dfaaa5266eb204f28214ed4f6449fa96523d (commit)
      from  6f77381ae8548f1599f230c4871f998f145e39e7 (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=4373dfaaa5266eb204f28214ed4f6449fa96523d
http://github.com/ceki/logback/commit/4373dfaaa5266eb204f28214ed4f6449fa96523d

commit 4373dfaaa5266eb204f28214ed4f6449fa96523d
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Thu Feb 10 13:07:18 2011 +0100

    fix LBCORE-193

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
index ebd2ec1..054b2cd 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
@@ -32,7 +32,7 @@ public class ConfigurationAction extends Action {
   boolean debugMode = false;
 
   public void begin(InterpretationContext ec, String name, Attributes attributes) {
-    String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
+    String debugAttrib = ec.subst(attributes.getValue(INTERNAL_DEBUG_ATTR));
 
     if (OptionHelper.isEmpty(debugAttrib)
         || debugAttrib.equalsIgnoreCase("false")
diff --git a/logback-classic/src/test/input/joran/lbcore193.xml b/logback-classic/src/test/input/joran/lbcore193.xml
new file mode 100644
index 0000000..168d9de
--- /dev/null
+++ b/logback-classic/src/test/input/joran/lbcore193.xml
@@ -0,0 +1,16 @@
+<configuration debug="${log.debug:-false}">
+    <!-- <property resource="configuration.properties"/> -->
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+             <!-- <pattern>%date %level [%thread] %logger(%file:%line\\) - %msg%n</pattern>     -->
+            <pattern>%date %level [%thread] %logger(%file:%line\)</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="scratch" level="${log.level:-INFO}"/>
+
+    <root level="${log-all.level:-DEBUG}">
+        <appender-ref ref="STDOUT"/>
+    </root>
+</configuration>
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
index 36e86af..9119aa0 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
@@ -20,6 +20,9 @@ import java.util.Date;
 import java.util.logging.LogManager;
 
 import ch.qos.logback.classic.jul.JULHelper;
+import ch.qos.logback.core.pattern.parser.Parser;
+import ch.qos.logback.core.pattern.parser.ScanException;
+import ch.qos.logback.core.status.Status;
 import ch.qos.logback.core.util.StatusPrinter;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -48,6 +51,7 @@ public class JoranConfiguratorTest {
   LoggerContext loggerContext = new LoggerContext();
   Logger logger = loggerContext.getLogger(this.getClass().getName());
   Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
+  StatusChecker sc = new StatusChecker(loggerContext);
 
   void configure(String file) throws JoranException {
     JoranConfigurator jc = new JoranConfigurator();
@@ -85,7 +89,7 @@ public class JoranConfiguratorTest {
     configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "additivity.xml");
     Logger logger = loggerContext.getLogger("additivityTest");
     assertFalse(logger.isAdditive());
-   }
+  }
 
   @Test
   public void rootLoggerLevelSettingBySystemProperty() throws JoranException {
@@ -391,4 +395,15 @@ public class JoranConfiguratorTest {
     configure(configFileAsStr);
   }
 
+  @Test
+  public void lbcore193() throws JoranException {
+    String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+            + "lbcore193.xml";
+    configure(configFileAsStr);
+    StatusPrinter.print(loggerContext);
+    sc.containsException(ScanException.class);
+    sc.containsMatch(Status.ERROR, "Expecting RIGHT_PARENTHESIS token but got null");
+    sc.containsMatch(Status.ERROR, "See also "+ Parser.MISSING_RIGHT_PARENTHESIS);
+  }
+
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
index d507887..f653926 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
@@ -130,7 +130,7 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
   }
 
   public String toString() {
-    return this.getClass().getName() + "(" + getPattern() + ")";
+    return this.getClass().getName() + "(\"" + getPattern() + "\")";
   }
 
   public Map<String, String> getInstanceConverterMap() {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java
index 2f807f7..8e8ce62 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java
@@ -41,7 +41,12 @@ class Compiler<E> extends ContextAwareBase {
           break;
         case Node.COMPOSITE_KEYWORD:
           CompositeNode cn = (CompositeNode) n;
-          CompositeConverter<E> compositeConverter = createCompiteConverter(cn);
+          CompositeConverter<E> compositeConverter = createCompositeConverter(cn);
+          if(compositeConverter == null) {
+            addError("Failed to create converter for [%"+cn.getValue()+"] keyword");
+            addToList(new LiteralConverter<E>("%PARSER_ERROR["+cn.getValue()+"]"));
+            break;
+          }
           compositeConverter.setFormattingInfo(cn.getFormatInfo());
           compositeConverter.setOptionList(cn.getOptions());
           Compiler<E> childCompiler = new Compiler<E>(cn.getChildNode(),
@@ -100,7 +105,7 @@ class Compiler<E> extends ContextAwareBase {
                 converterClassStr, DynamicConverter.class, context);
       } catch (Exception e) {
         addError("Failed to instantiate converter class [" + converterClassStr
-                + "]", e);
+                + "] for keyword ["+keyword+"]", e);
         return null;
       }
     } else {
@@ -118,7 +123,7 @@ class Compiler<E> extends ContextAwareBase {
    * @return
    */
   @SuppressWarnings("unchecked")
-  CompositeConverter<E> createCompiteConverter(CompositeNode cn) {
+  CompositeConverter<E> createCompositeConverter(CompositeNode cn) {
     String keyword = (String) cn.getValue();
     String converterClassStr = (String) converterMap.get(keyword);
 
@@ -128,7 +133,7 @@ class Compiler<E> extends ContextAwareBase {
                 converterClassStr, CompositeConverter.class, context);
       } catch (Exception e) {
         addError("Failed to instantiate converter class [" + converterClassStr
-                + "]", e);
+                + "] as a composite converter for keyword ["+keyword+"]", e);
         return null;
       }
     } else {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java
index 0d30413..94647c4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java
@@ -17,6 +17,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.pattern.Converter;
 import ch.qos.logback.core.pattern.FormatInfo;
 import ch.qos.logback.core.pattern.IdentityCompositeConverter;
@@ -43,6 +44,7 @@ import ch.qos.logback.core.spi.ContextAwareBase;
 
 public class Parser<E> extends ContextAwareBase {
 
+  public final static String MISSING_RIGHT_PARENTHESIS = CoreConstants.CODES_URL+"#missingRightParenthesis";
   public final static Map<String, String> DEFAULT_COMPOSITE_CONVERTER_MAP = new HashMap<String, String>();
   public final static String REPLACE_CONVERTER_WORD = "replace";
   static {
@@ -186,18 +188,15 @@ public class Parser<E> extends ContextAwareBase {
     CompositeNode compositeNode = new CompositeNode(keyword);
 
     Node childNode = E();
-    // System.out.println("Child node: " + childNode);
-
     compositeNode.setChildNode(childNode);
 
     Token t = getNextToken();
-    // System.out.println("Next token is" + t);
 
-    if (t.getType() != Token.RIGHT_PARENTHESIS) {
-      throw new IllegalStateException(
-          "Expecting RIGHT_PARENTHESIS token but got " + t);
-    } else {
-      // System.out.println("got expected ')'");
+    if (t == null || t.getType() != Token.RIGHT_PARENTHESIS) {
+        String msg = "Expecting RIGHT_PARENTHESIS token but got " + t;
+        addError(msg);
+        addError("See also "+MISSING_RIGHT_PARENTHESIS);
+        throw new ScanException(msg);
     }
     Token ot = getCurentToken();
     if (ot != null && ot.getType() == Token.OPTION) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
index 960c63a..02e75b7 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
@@ -76,7 +76,7 @@ public class FileAppenderResilienceTest {
 
     double bestCaseSuccessRatio = 1/delayCoeff;
     ResilienceUtil
-        .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio*0.9);
+        .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio*0.8);
   }
 }
 
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
index 58f7f52..91bc97f 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
@@ -14,11 +14,17 @@
 package ch.qos.logback.core.pattern.parser;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.util.StatusPrinter;
 import org.junit.Test;
 
 import ch.qos.logback.core.pattern.FormatInfo;
@@ -26,6 +32,8 @@ import ch.qos.logback.core.pattern.FormatInfo;
 public class ParserTest {
 
   String BARE = Token.BARE_COMPOSITE_KEYWORD_TOKEN.getValue().toString();
+  Context context = new ContextBase();
+
 
   @Test
   public void testBasic() throws Exception {
@@ -135,8 +143,9 @@ public class ParserTest {
       composite.next = new Node(Node.LITERAL, " ");
       composite.next.next = new SimpleKeywordNode("m");
       assertEquals(witness, t);
-
     }
+
+
   }
 
   @Test
@@ -240,20 +249,18 @@ public class ParserTest {
 
   @Test
   public void testCompositeFormatting() throws Exception {
+    Parser p = new Parser("hello%5(XYZ)");
+    Node t = p.parse();
 
-    {
-      Parser p = new Parser("hello%5(XYZ)");
-      Node t = p.parse();
+    Node witness = new Node(Node.LITERAL, "hello");
+    CompositeNode composite = new CompositeNode(BARE);
+    composite.setFormatInfo(new FormatInfo(5, Integer.MAX_VALUE));
+    Node child = new Node(Node.LITERAL, "XYZ");
+    composite.setChildNode(child);
+    witness.next = composite;
 
-      Node witness = new Node(Node.LITERAL, "hello");
-      CompositeNode composite = new CompositeNode(BARE);
-      composite.setFormatInfo(new FormatInfo(5, Integer.MAX_VALUE));
-      Node child = new Node(Node.LITERAL, "XYZ");
-      composite.setChildNode(child);
-      witness.next = composite;
+    assertEquals(witness, t);
 
-      assertEquals(witness, t);
-    }
   }
 
   @Test
@@ -266,4 +273,20 @@ public class ParserTest {
 
     }
   }
+
+  @Test
+  public void lbcore193() throws Exception {
+    try {
+      Parser p = new Parser("hello%(abc");
+      p.setContext(context);
+      Node t = p.parse();
+      fail("where the is exception?");
+    } catch (ScanException ise) {
+      assertEquals("Expecting RIGHT_PARENTHESIS token but got null", ise.getMessage());
+    }
+    StatusChecker sc = new StatusChecker(context);
+    assertTrue(sc.containsMatch("Expecting RIGHT_PARENTHESIS"));
+    assertTrue(sc.containsMatch("See also " + Parser.MISSING_RIGHT_PARENTHESIS));
+  }
+
 }
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
index f695205..8887fe1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
@@ -342,6 +342,24 @@ public class TokenStreamTest {
       witness.add(new Token(Token.LITERAL, ")"));
       assertEquals(witness, tl);
     }
+    {
+      List tl = new TokenStream("%a(x\\)").tokenize();
+      List<Token> witness = new ArrayList<Token>();
+      witness.add(Token.PERCENT_TOKEN);
+      witness.add(new Token(Token.COMPOSITE_KEYWORD, "a"));
+      witness.add(new Token(Token.LITERAL, "x)"));
+      assertEquals(witness, tl);
+    }
+    {
+      List tl = new TokenStream("%a\\(x)").tokenize();
+      List<Token> witness = new ArrayList<Token>();
+      witness.add(Token.PERCENT_TOKEN);
+      witness.add(new Token(Token.SIMPLE_KEYWORD, "a"));
+      witness.add(new Token(Token.LITERAL, "(x"));
+      witness.add(new Token(Token.RIGHT_PARENTHESIS));
+
+      assertEquals(witness, tl);
+    }
   }
 
   @Test
diff --git a/logback-site/src/site/pages/codes.html b/logback-site/src/site/pages/codes.html
index 7bf4ac2..88894ac 100644
--- a/logback-site/src/site/pages/codes.html
+++ b/logback-site/src/site/pages/codes.html
@@ -397,8 +397,8 @@
   &lt;/encoder>
 &lt;/appender></pre>
 
-   <p>For <code>FixedWindowRollingPolicy</code>, the file option is
-   mandatory.
+   <p>Note that for <code>FixedWindowRollingPolicy</code>, the <span
+   class="option">file</span> property is mandatory.
    </p>
  
   
@@ -515,6 +515,22 @@ if(logger.equals("org.apache.http.wire") &amp;&amp;
 
 return false;</pre>
 
+   <p>
+   </p>
+   <hr/>
+   <!-- ============================================================= -->
+   <p><a name="missingRightParenthesis"
+   href="#missingRightParenthesis">In a conversion pattern, opened
+   parenthesis must be closed.</a>
+   </p>
+   
+   <p>In conversion patterns, <a
+   href="manual/layouts.html#Parentheses">parentheses are special</a>
+   because they are treated as grouping tokens. If a parenthesis
+   character needs to be viewed as a literal, it needs to be escaped
+   by preceding each parenthesis with a backslash. As in,
+   <b>\(</b>%d{HH:mm:ss.SSS} [%thread]<b>\) </b>.
+   </p>
   
   <script src="templates/footer.js" type="text/javascript"></script>
   </div>
diff --git a/logback-site/src/site/pages/manual/layouts.html b/logback-site/src/site/pages/manual/layouts.html
index 6399a4b..95de04c 100644
--- a/logback-site/src/site/pages/manual/layouts.html
+++ b/logback-site/src/site/pages/manual/layouts.html
@@ -1263,7 +1263,9 @@ Caller+2   at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
 
     <p>In logback, parentheses within the pattern string are treated
     as grouping tokens. Thus, it is possible to group a sub-pattern
-    and apply formatting directives on that sub-pattern.
+    and apply formatting directives on that sub-pattern. As of version
+    0.9.27, logback supports composite conversion words such as <a
+    href="#replace">%replace</a> which can transform sub-patterns.
     </p>
 
     <p>For example, the pattern</p> 
@@ -1300,18 +1302,12 @@ Caller+2   at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
     </p>
 
     
-    <p>The latter form is more comfortable to read, especially for
-    long log files.</p>
+    <p>The latter form is more comfortable to read.</p>
     
     <p>If you need to treat the parenthesis character as a literal, it
     needs to be escaped by preceding each parenthesis with a
     backslash. As in, <b>\(</b>%d{HH:mm:ss.SSS}
-    [%thread]<b>\)</b>. Strictly speaking, only the closing parenthesis
-    needs to be escaped. Thus, "<b>(</b>%d&nbsp;[%thread]<b>\)</b>" is
-    equivalent to "<b>\(</b>%d&nbsp;[%thread]<b>\)</b>". But since it
-    is not easy to recall which parenthesis needs escaping and which
-    doesn't, you can escape both so that they are
-    interpreted as literals.
+    [%thread]<b>\)</b>. 
     </p>
 
 		<h2><a name="Evaluators" href="#Evaluators">Evaluators</a></h2>
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 52db323..739c3d4 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -37,6 +37,12 @@
     as reported by Joern Huxhorn.
     </p>
 
+    <p>Logback now emits a clearer error message in case a conversion
+    pattern misses a closing parenthesis or if an openening
+    parenthesis is misplaced. This fixes <a
+    href="http://jira.qos.ch/browse/LBCORE-193">LBCORE-193</a>
+    reported by B. K. Oxley.</p>
+
     <hr width="80%" align="center" />
 
     <h3>January 25th, 2011 - Release of version 0.9.28</h3>

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

Summary of changes:
 .../classic/joran/action/ConfigurationAction.java  |    2 +-
 logback-classic/src/test/input/joran/lbcore193.xml |   16 +++++++
 .../classic/joran/JoranConfiguratorTest.java       |   17 +++++++-
 .../logback/core/pattern/PatternLayoutBase.java    |    2 +-
 .../qos/logback/core/pattern/parser/Compiler.java  |   13 ++++--
 .../ch/qos/logback/core/pattern/parser/Parser.java |   15 +++---
 .../logback/core/FileAppenderResilienceTest.java   |    2 +-
 .../logback/core/pattern/parser/ParserTest.java    |   47 +++++++++++++++-----
 .../core/pattern/parser/TokenStreamTest.java       |   18 ++++++++
 logback-site/src/site/pages/codes.html             |   20 ++++++++-
 logback-site/src/site/pages/manual/layouts.html    |   14 ++----
 logback-site/src/site/pages/news.html              |    6 +++
 12 files changed, 133 insertions(+), 39 deletions(-)
 create mode 100644 logback-classic/src/test/input/joran/lbcore193.xml


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


More information about the logback-dev mailing list