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

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Wed May 25 16:34:02 CEST 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  79989e013e314dd815b23a12fea8bcd5e16fcc49 (commit)
      from  e4aa27eb1dae6b6278ab139444d769edf1280411 (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=79989e013e314dd815b23a12fea8bcd5e16fcc49
http://github.com/ceki/logback/commit/79989e013e314dd815b23a12fea8bcd5e16fcc49

commit 79989e013e314dd815b23a12fea8bcd5e16fcc49
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed May 25 16:23:38 2011 +0200

    Fixed LBCORE-199 by adding a timestamp to the entry found in the zip file. This was suggested by Benoit Xhenseval.

diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java
index 7cb9a09..5057942 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java
@@ -37,6 +37,8 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase {
   RenameUtil util = new RenameUtil();
   Compressor compressor;
 
+  public static String ZIP_ENTRY_DATE_PATTERN = "yyyy-MM-dd_HHmm";
+
   /**
    * It's almost always a bad idea to have a large window size, say over 12.
    */
@@ -104,7 +106,7 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase {
   private String transformFileNamePatternFromInt2Date(String fileNamePatternStr) {
     String slashified = FileFilterUtil.slashify(fileNamePatternStr);
     String stemOfFileNamePattern = FileFilterUtil.afterLastSlash(slashified);
-    return stemOfFileNamePattern.replace("%i", "%d");
+    return stemOfFileNamePattern.replace("%i", "%d{"+ZIP_ENTRY_DATE_PATTERN+"}");
   }
 
   public void rollover() throws RolloverFailure {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
index 4e76249..36b5cd0 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
@@ -13,11 +13,16 @@
  */
 package ch.qos.logback.core.rolling;
 
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 import org.junit.After;
 import org.junit.Before;
@@ -30,12 +35,10 @@ import ch.qos.logback.core.encoder.EchoEncoder;
 import ch.qos.logback.core.util.CoreTestConstants;
 
 /**
- * 
  * Do not forget to call start() when configuring programatically.
- * 
+ *
  * @author Ceki G&uuml;lc&uuml;
  * @author S&eacute;bastien Pennec
- * 
  */
 public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
 
@@ -45,13 +48,13 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
     super.setUp();
     {
       File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
-          + "sizeBased-smoke.log");
+              + "sizeBased-smoke.log");
       target.mkdirs();
       target.delete();
     }
     {
       File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
-          + "sbr-test3.log");
+              + "sbr-test3.log");
       target.mkdirs();
       target.delete();
     }
@@ -83,7 +86,7 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
     sbtp.setMaxFileSize("100");
     sbtp.start();
     fwrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX
-        + "sizeBased-test1.%i");
+            + "sizeBased-test1.%i");
     try {
       fwrp.start();
       fail("The absence of activeFileName option should have caused an exception.");
@@ -125,7 +128,7 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
     String prefix = "hello";
     for (int i = 0; i < runLength; i++) {
       Thread.sleep(10);
-      rfa.doAppend(prefix+i);
+      rfa.doAppend(prefix + i);
     }
 
     expectedFilenameList.add(randomOutputDir + "a-sizeBased-smoke.log");
@@ -167,12 +170,12 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
     String prefix = "hello";
     for (int i = 0; i < runLength; i++) {
       Thread.sleep(10);
-      rfa.doAppend("hello"+i);
+      rfa.doAppend("hello" + i);
     }
 
-    expectedFilenameList.add(randomOutputDir        + "a-sbr-test3.log");
-    expectedFilenameList.add(randomOutputDir        + "sbr-test3.0.gz");
-    expectedFilenameList.add(randomOutputDir        + "sbr-test3.1.gz");
+    expectedFilenameList.add(randomOutputDir + "a-sbr-test3.log");
+    expectedFilenameList.add(randomOutputDir + "sbr-test3.0.gz");
+    expectedFilenameList.add(randomOutputDir + "sbr-test3.1.gz");
 
     existenceCheck(expectedFilenameList);
     reverseSortedContentCheck(randomOutputDir, runLength, prefix);
@@ -206,11 +209,11 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
     String prefix = "hello";
     for (int i = 0; i < runLength; i++) {
       Thread.sleep(10);
-      rfa.doAppend("hello"+i);
+      rfa.doAppend("hello" + i);
     }
-    expectedFilenameList.add(randomOutputDir        + "a-sbr-test3.log");
-    expectedFilenameList.add(randomOutputDir        + "sbr-test3.0.zip");
-    expectedFilenameList.add(randomOutputDir        + "sbr-test3.1.zip");
+    expectedFilenameList.add(randomOutputDir + "a-sbr-test3.log");
+    expectedFilenameList.add(randomOutputDir + "sbr-test3.0.zip");
+    expectedFilenameList.add(randomOutputDir + "sbr-test3.1.zip");
 
     existenceCheck(expectedFilenameList);
     reverseSortedContentCheck(randomOutputDir, runLength, prefix);
@@ -219,17 +222,25 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
 
   }
 
-  private void zipEntryNameCheck(List<String> expectedFilenameList) {
-    for(String filepath: expectedFilenameList) {
-      if(filepath.endsWith(".zip")) {
-        checkZipEntyName(filepath, "sbr-test3.%i.zip");
+  private void zipEntryNameCheck(List<String> expectedFilenameList) throws IOException {
+    for (String filepath : expectedFilenameList) {
+      if (filepath.endsWith(".zip")) {
+        checkZipEntryName(filepath, "sbr-test3.%i.zip");
       }
     }
   }
 
   SimpleDateFormat SDF = new SimpleDateFormat();
-  private void checkZipEntyName(String filepath, String pattern) {
-      fail("to be continued");
+
+  private void checkZipEntryName(String filepath, String pattern) throws IOException {
+    System.out.println("Checking ["+filepath+"]");
+    ZipFile zf = new ZipFile(filepath);
+    Enumeration entries = zf.entries();
+    assert(entries.hasMoreElements());
+    ZipEntry firstZipEntry = (ZipEntry) entries.nextElement();
+    assert(!entries.hasMoreElements());
+    System.out.println("Testing zip entry ["+firstZipEntry.getName()+"]");
+    assertTrue(firstZipEntry.getName().matches("sbr-test3.20\\d{2}-\\d{2}-\\d{2}_\\d{4}"));
 
   }
 }
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala
index 8dcb859..1d79982 100644
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala
@@ -36,7 +36,6 @@ class LBCORE_199 extends RollingScaffolding {
 
   @Test
   def smoke() {
-    println("ba")
     initRFA("toto.log")
     fwrp.setFileNamePattern("tests.%i.log.zip")
     fwrp.minIndex = 1

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

Summary of changes:
 .../core/rolling/FixedWindowRollingPolicy.java     |    4 +-
 .../logback/core/rolling/SizeBasedRollingTest.java |   53 ++++++++++++--------
 .../ch/qos/logback/core/rolling/LBCORE_199.scala   |    1 -
 3 files changed, 35 insertions(+), 23 deletions(-)


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


More information about the logback-dev mailing list