[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.1-18-g7c700af

Gitbot git-noreply at pixie.qos.ch
Sun Apr 22 18:31:27 CEST 2012


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  7c700af7b2a87bd0344af92931ecc2e413e3ea87 (commit)
      from  8646e9a3a29560176174aed181dbbd93de56c49f (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=7c700af7b2a87bd0344af92931ecc2e413e3ea87
http://github.com/ceki/logback/commit/7c700af7b2a87bd0344af92931ecc2e413e3ea87

commit 7c700af7b2a87bd0344af92931ecc2e413e3ea87
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Sun Apr 22 18:30:38 2012 +0200

    minor refactorings, edits

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java
index e184610..e97ceb3 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java
@@ -45,27 +45,34 @@ public class MDCConverter extends ClassicConverter {
     }
 
     if (key == null) {
-      // if no key is specified, return all the
-      // values present in the MDC, separated with a single space.
-      StringBuilder buf = new StringBuilder();
-      boolean first = true;
-      for(Map.Entry<String, String> entry : mdcPropertyMap.entrySet()) {
-        if(first) {
-          first = false;
-        } else {
-          buf.append(", ");
-        }
-        //format: {testKey=testValue, testKey2=testValue2}
-        buf.append(entry.getKey()).append('=').append(entry.getValue());
+      return outputMDCForAllKeys(mdcPropertyMap);
+    } else {
+
+      String value = event.getMDCPropertyMap().get(key);
+      if (value != null) {
+        return value;
+      } else {
+        return EMPTY_STRING;
       }
-      return buf.toString();
     }
+  }
 
-    String value = event.getMDCPropertyMap().get(key);
-    if (value != null) {
-      return value;
-    } else {
-      return EMPTY_STRING;
+  /**
+   * if no key is specified, return all the values present in the MDC, in the format "k1=v1, k2=v2, ..."
+   */
+
+  private String outputMDCForAllKeys(Map<String, String> mdcPropertyMap) {
+    StringBuilder buf = new StringBuilder();
+    boolean first = true;
+    for (Map.Entry<String, String> entry : mdcPropertyMap.entrySet()) {
+      if (first) {
+        first = false;
+      } else {
+        buf.append(", ");
+      }
+      //format: key0=value0, key1=value1
+      buf.append(entry.getKey()).append('=').append(entry.getValue());
     }
+    return buf.toString();
   }
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
index 10fd4bc..d13f761 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
@@ -29,7 +29,7 @@ abstract public class Converter<E> {
    * 
    * @param event
    */
-  public abstract String  convert(E event);
+  public abstract String convert(E event);
 
   /**
    * In its simplest incarnation, a convert simply appends the data extracted from
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 081553d..8e766d6 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
@@ -15,7 +15,10 @@ package ch.qos.logback.core.pattern.parser;
 
 import java.util.Map;
 
-import ch.qos.logback.core.pattern.*;
+import ch.qos.logback.core.pattern.CompositeConverter;
+import ch.qos.logback.core.pattern.Converter;
+import ch.qos.logback.core.pattern.DynamicConverter;
+import ch.qos.logback.core.pattern.LiteralConverter;
 import ch.qos.logback.core.spi.ContextAwareBase;
 import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.util.OptionHelper;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java
index 90a59ab..cba9645 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java
@@ -82,8 +82,8 @@ public class DateTokenConverter<E> extends DynamicConverter<E> implements MonoTy
   }
 
   public String toRegex() {
-    DatePatternToRegexUtil toRegex = new DatePatternToRegexUtil(datePattern);
-    return toRegex.toRegex();
+    DatePatternToRegexUtil datePatternToRegexUtil = new DatePatternToRegexUtil(datePattern);
+    return datePatternToRegexUtil.toRegex();
   }
 
   public boolean isPrimary() {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java
index 961ad4f..5a43bc3 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java
@@ -31,7 +31,7 @@ class CharSequenceToRegexMapper {
       return ".*";
     case 'M':
       if (occurrences >= 3) {
-        return ".\\{3,12}";
+        return ".{3,12}";
       } else {
         return number(occurrences);
       }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java
index ad546f7..ff001be 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java
@@ -29,12 +29,12 @@ public class DatePatternToRegexUtil {
   final int datePatternLength;
   final CharSequenceToRegexMapper regexMapper = new CharSequenceToRegexMapper();
 
-  DatePatternToRegexUtil(String datePattern) {
+  public DatePatternToRegexUtil(String datePattern) {
     this.datePattern = datePattern;
     datePatternLength = datePattern.length();
   }
 
-  String toRegex() {
+  public String toRegex() {
     List<CharSequenceState> charSequenceList = tokenize();
     StringBuilder sb = new StringBuilder();
     for (CharSequenceState seq : charSequenceList) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java
index b309a9a..adb6833 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java
@@ -13,6 +13,7 @@
  */
 package ch.qos.logback.core.rolling.helper;
 
+import ch.qos.logback.core.util.DatePatternToRegexTest;
 import junit.framework.TestCase;
 
 import org.junit.runner.RunWith;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java
similarity index 85%
rename from logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java
rename to logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java
index 9b255ea..8281b8f 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java
@@ -11,7 +11,7 @@
  * under the terms of the GNU Lesser General Public License version 2.1
  * as published by the Free Software Foundation.
  */
-package ch.qos.logback.core.rolling.helper;
+package ch.qos.logback.core.util;
 
 import static org.junit.Assert.assertTrue;
 
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 
+import ch.qos.logback.core.rolling.helper.DateTokenConverter;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -28,19 +29,26 @@ import ch.qos.logback.core.CoreConstants;
 public class DatePatternToRegexTest {
   static Calendar CAL_2009_08_3_NIGHT = Calendar.getInstance();
   static Calendar CAL_2009_08_3_MORNING = Calendar.getInstance();
-  
+
   @BeforeClass
   public static void setUpCalendars() {
     CAL_2009_08_3_NIGHT.set(2009, 8, 3, 21, 57, 16);
     CAL_2009_08_3_NIGHT.set(Calendar.MILLISECOND, 333);
-      
+
     CAL_2009_08_3_MORNING.set(2009, 8, 3, 10, 24, 37);
     CAL_2009_08_3_MORNING.set(Calendar.MILLISECOND, 333);
   }
-  
+
   @Test
   public void ISO8601() {
-    doTest(CoreConstants.ISO8601_PATTERN, CAL_2009_08_3_NIGHT);;
+    doTest(CoreConstants.ISO8601_PATTERN, CAL_2009_08_3_NIGHT);
+    ;
+  }
+
+  @Test
+  public void withQuotes() {
+    doTest("yyyy-MM-dd'T'HH:mm:ss,SSS", CAL_2009_08_3_NIGHT);
+    ;
   }
 
   @Test
@@ -49,19 +57,18 @@ public class DatePatternToRegexTest {
     doTest("yyyy-MMMM-dd", CAL_2009_08_3_NIGHT);
   }
 
-
   @Test
   public void dot() {
-    doTest("yyyy.MMM.dd", CAL_2009_08_3_NIGHT);;
+    doTest("yyyy.MMM.dd", CAL_2009_08_3_NIGHT);
+    ;
   }
-  
+
   @Test
   public void timeZone() {
     doTest("yyyy-MMM-dd HH:mm:ss z", CAL_2009_08_3_NIGHT);
     doTest("yyyy-MMM-dd HH:mm:ss Z", CAL_2009_08_3_NIGHT);
   }
 
-  
   @Test
   public void dayInWeek() {
     doTest("yyyy-MMM-E", CAL_2009_08_3_NIGHT);
@@ -72,7 +79,7 @@ public class DatePatternToRegexTest {
   @Test
   public void amPm() {
     doTest("yyyy-MM-dd a", CAL_2009_08_3_NIGHT);
-    doTest("yyyy-MM-dd a", CAL_2009_08_3_MORNING);    
+    doTest("yyyy-MM-dd a", CAL_2009_08_3_MORNING);
   }
 
 
@@ -81,22 +88,22 @@ public class DatePatternToRegexTest {
     DateTokenConverter dtc = makeDTC(datePattern);
     verify(sdf, calendar, dtc, slashified);
   }
-  
+
   void doTest(String datePattern, Calendar calendar) {
     doTest(datePattern, calendar, false);
   }
- 
-  
-  void verify(SimpleDateFormat sdf, Calendar calendar, DateTokenConverter dtc,  boolean slashified) {
+
+
+  void verify(SimpleDateFormat sdf, Calendar calendar, DateTokenConverter dtc, boolean slashified) {
     String expected = sdf.format(calendar.getTime());
-    if(slashified) {
+    if (slashified) {
       expected = expected.replace('\\', '/');
     }
     String regex = dtc.toRegex();
     //System.out.println("expected="+expected);
     //System.out.println(regex);
     assertTrue("[" + expected + "] does not match regex [" + regex + "]",
-        expected.matches(regex));
+            expected.matches(regex));
   }
 
   private DateTokenConverter makeDTC(String datePattern) {
diff --git a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
index 7598b80..48fdae4 100644
--- a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
+++ b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
@@ -83,7 +83,7 @@ public class SimpleMDC {
     try {
       JoranConfigurator configurator = new JoranConfigurator();
       configurator.setContext(lc);
-      lc.stop();
+      lc.reset();
       URL url = Loader.getResourceBySelfClassLoader("chapters/mdc/simpleMDC.xml");
       configurator.doConfigure(url);
     } catch (JoranException je) {
diff --git a/logback-site/src/site/pages/manual/layouts.html b/logback-site/src/site/pages/manual/layouts.html
index dd20da2..c3cfa3d 100644
--- a/logback-site/src/site/pages/manual/layouts.html
+++ b/logback-site/src/site/pages/manual/layouts.html
@@ -774,14 +774,14 @@ Caller+2   at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
 				<td>
 
 					<p>
-						Outputs the MDC (mapped diagnostic
-						context) associated with the thread that
-						generated the logging event.
+						Outputs the MDC (mapped diagnostic context) associated
+						with the thread that generated the logging event.
 					</p>
 
 					<p>If the <b>mdc</b> conversion word is followed by a key
-					between braces, as in <b>%mdc{clientNumber}</b>, then the
-					value in the MDC corresponding to the key will be output.
+					between braces, as in <b>%mdc{userid}</b>, then the MDC
+					value corresponding to the key 'userid' will be output. If
+					the that value is null, the empty string is output.
 					</p>
 
 					<p>If no option is given, then the entire content of the MDC
@@ -789,7 +789,7 @@ Caller+2   at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
 					</p>
 
 					<p>See the <a href="mdc.html">chapter on MDC</a> for more
-					details.
+					details on the subject.
 					</p>
 
 				</td>

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

Summary of changes:
 .../qos/logback/classic/pattern/MDCConverter.java  |   43 +++++++++++--------
 .../ch/qos/logback/core/pattern/Converter.java     |    2 +-
 .../qos/logback/core/pattern/parser/Compiler.java  |    5 ++-
 .../core/rolling/helper/DateTokenConverter.java    |    4 +-
 .../core/util/CharSequenceToRegexMapper.java       |    2 +-
 .../logback/core/util/DatePatternToRegexUtil.java  |    4 +-
 .../logback/core/rolling/helper/PackageTest.java   |    1 +
 .../helper => util}/DatePatternToRegexTest.java    |   39 ++++++++++-------
 .../src/main/java/chapters/mdc/SimpleMDC.java      |    2 +-
 logback-site/src/site/pages/manual/layouts.html    |   12 +++---
 10 files changed, 66 insertions(+), 48 deletions(-)
 rename logback-core/src/test/java/ch/qos/logback/core/{rolling/helper => util}/DatePatternToRegexTest.java (85%)


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


More information about the logback-dev mailing list