[logback-dev] svn commit: r1646 - in logback/trunk: logback-classic/src/test/java/ch/qos/logback/classic logback-core/src/main/java/ch/qos/logback/core/html logback-core/src/main/java/ch/qos/logback/core/pattern logback-core/src/main/java/ch/qos/logback/core/rolling/helper

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Mar 18 22:10:40 CET 2008


Author: ceki
Date: Tue Mar 18 22:10:40 2008
New Revision: 1646

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java

Log:
- composite patterns (those with parentheses) pass initial tests
- startConverters method moved from DynamicConverter to ConvertUtil class. 
  In fact, CompositeConverter have to be started as well. This was previously not the case
  and patterns with composites in them would not work. 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	Tue Mar 18 22:10:40 2008
@@ -78,6 +78,20 @@
     assertTrue(val.contains("java.lang.Exception: Bogus exception"));
   }
 
+  public void testCompositePattern() {
+    PatternLayout pl = new PatternLayout();
+    pl.setPattern("%-56(%d [%t] %lo{20}) - %m%n");
+    Context context = new LoggerContext();
+    pl.setContext(context);
+    pl.start();
+    String val = pl.doLayout(getEventObject());
+    // 2008-03-18 21:55:54,250 [main] c.q.l.c.pattern.ConverterTest - Some message
+    String regex = Contants4T.ISO_REGEX+" \\[main] c.q.l.c.p.ConverterTest   - Some message\\s*";
+    System.out.println(val);
+    assertTrue(val.matches(regex));
+
+  }
+  
   public void testNopExeptionHandler() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("%nopex %m%n");

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	Tue Mar 18 22:10:40 2008
@@ -4,7 +4,7 @@
 
 import ch.qos.logback.core.LayoutBase;
 import ch.qos.logback.core.pattern.Converter;
-import ch.qos.logback.core.pattern.DynamicConverter;
+import ch.qos.logback.core.pattern.ConverterUtil;
 import ch.qos.logback.core.pattern.parser.Node;
 import ch.qos.logback.core.pattern.parser.Parser;
 import ch.qos.logback.core.pattern.parser.ScanException;
@@ -74,7 +74,7 @@
       p.setContext(getContext());
       Node t = p.parse();
       this.head = p.compile(t, getDefaultConverterMap());
-      DynamicConverter.startConverters(this.head);
+      ConverterUtil.startConverters(this.head);
     } catch (ScanException ex) {
       addError("Incorrect pattern found", ex);
       errorCount++;

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java	Tue Mar 18 22:10:40 2008
@@ -52,19 +52,4 @@
   protected List getOptionList() {
     return optionList;
   }
-  
-  /**
-   * Used to start DynamicConvertes in a chain of converters.
-   * @param head
-   */
-  public static void startConverters(Converter head) {
-    Converter c = head;
-    while (c != null) {
-      if (c instanceof DynamicConverter) {
-        DynamicConverter dc = (DynamicConverter) c;
-        dc.start();
-      }
-      c = c.getNext();
-    }
-  }
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java	Tue Mar 18 22:10:40 2008
@@ -78,7 +78,7 @@
       Node t = p.parse();
       this.head = p.compile(t, getEffectiveConverterMap());
       postCompileProcessing(head);
-      DynamicConverter.startConverters(this.head);
+      ConverterUtil.startConverters(this.head);
       super.start();
     } catch (ScanException sce) {
       StatusManager sm = getContext().getStatusManager();

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java	Tue Mar 18 22:10:40 2008
@@ -16,7 +16,7 @@
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.pattern.Converter;
-import ch.qos.logback.core.pattern.DynamicConverter;
+import ch.qos.logback.core.pattern.ConverterUtil;
 import ch.qos.logback.core.pattern.parser.Node;
 import ch.qos.logback.core.pattern.parser.Parser;
 import ch.qos.logback.core.pattern.parser.ScanException;
@@ -47,7 +47,7 @@
     setPattern(patternArg);
     setContext(contextArg);
     parse();
-    DynamicConverter.startConverters(this.headTokenConverter);
+    ConverterUtil.startConverters(this.headTokenConverter);
   }
 
   void parse() {



More information about the logback-dev mailing list