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

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Fri Mar 11 19:04:23 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  f23196e82fa25ef60ea80ad0470e6dd074cdc3ae (commit)
      from  a7582c96029b7666fb2a0380dd8a60af2cce613c (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=f23196e82fa25ef60ea80ad0470e6dd074cdc3ae
http://github.com/ceki/logback/commit/f23196e82fa25ef60ea80ad0470e6dd074cdc3ae

commit f23196e82fa25ef60ea80ad0470e6dd074cdc3ae
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Mar 11 19:01:25 2011 +0100

    fixing LBCORE-199

diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index 0989645..c58081e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -35,6 +35,7 @@ public class CoreConstants {
 
   public static final String ISO8601_STR = "ISO8601";
   public static final String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
+  public static final String DAILY_DATE_PATTERN = "yyyy-MM-dd";
 
   /**
    * Time format used in Common Log Format
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 556f45e..7cb9a09 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
@@ -14,12 +14,10 @@
 package ch.qos.logback.core.rolling;
 
 import java.io.File;
+import java.util.Date;
 
 import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.rolling.helper.Compressor;
-import ch.qos.logback.core.rolling.helper.FileNamePattern;
-import ch.qos.logback.core.rolling.helper.IntegerTokenConverter;
-import ch.qos.logback.core.rolling.helper.RenameUtil;
+import ch.qos.logback.core.rolling.helper.*;
 
 /**
  * When rolling over, <code>FixedWindowRollingPolicy</code> renames files
@@ -38,7 +36,7 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase {
   int minIndex;
   RenameUtil util = new RenameUtil();
   Compressor compressor;
-  
+
   /**
    * It's almost always a bad idea to have a large window size, say over 12.
    */
@@ -94,11 +92,21 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase {
           + "] does not contain a valid IntegerToken");
     }
 
+    if(compressionMode == CompressionMode.ZIP) {
+      String zipEntryFileNamePatternStr = transformFileNamePatternFromInt2Date(fileNamePatternStr);
+      zipEntryFileNamePattern = new FileNamePattern(zipEntryFileNamePatternStr, context);
+    }
     compressor = new Compressor(compressionMode);
     compressor.setContext(this.context);
     super.start();
   }
 
+  private String transformFileNamePatternFromInt2Date(String fileNamePatternStr) {
+    String slashified = FileFilterUtil.slashify(fileNamePatternStr);
+    String stemOfFileNamePattern = FileFilterUtil.afterLastSlash(slashified);
+    return stemOfFileNamePattern.replace("%i", "%d");
+  }
+
   public void rollover() throws RolloverFailure {
 
     // Inside this method it is guaranteed that the hereto active log file is
@@ -131,17 +139,17 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase {
             .convertInt(minIndex));
         break;
       case GZ:
+        compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
+        break;
       case ZIP:
-        compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex));
+        compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date()));
         break;
       }
     }
   }
 
   /**
-   * Return the value of the <b>ActiveFile</b> option.
-   * 
-   * @see {@link setActiveFileName}.
+   * Return the value of the parent's RawFile property.
    */
   public String getActiveFileName() {
     return getParentsRawFileProperty();
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java
index 5f47444..df69816 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java
@@ -33,6 +33,8 @@ public abstract class RollingPolicyBase extends ContextAwareBase implements
 
   private FileAppender parent;
 
+  // use to name files within zip file, i.e. the zipEntry
+  FileNamePattern zipEntryFileNamePattern;
   private boolean started;
 
   /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java
index 5328db7..91f67fa 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java
@@ -86,10 +86,6 @@ abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends
     this.dateInCurrentPeriod = _dateInCurrentPeriod;
   }
 
-  public Date getDateInCurrentPeriod() {
-    return dateInCurrentPeriod;
-  }
-
   public String getElapsedPeriodsFileName() {
     return elapsedPeriodsFileName;
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
index 1159aa5..8ebe445 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
@@ -18,12 +18,8 @@ import java.util.Date;
 import java.util.concurrent.Future;
 
 import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.rolling.helper.ArchiveRemover;
-import ch.qos.logback.core.rolling.helper.AsynchronousCompressor;
-import ch.qos.logback.core.rolling.helper.CompressionMode;
-import ch.qos.logback.core.rolling.helper.Compressor;
-import ch.qos.logback.core.rolling.helper.FileNamePattern;
-import ch.qos.logback.core.rolling.helper.RenameUtil;
+import ch.qos.logback.core.rolling.helper.*;
+import ch.qos.logback.core.util.FileUtil;
 
 /**
  * <code>TimeBasedRollingPolicy</code> is both easy to configure and quite
@@ -77,6 +73,11 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     addInfo("Will use the pattern " + fileNamePatternWCS
         + " for the active file");
 
+     if(compressionMode == CompressionMode.ZIP) {
+      String zipEntryFileNamePatternStr = transformFileNamePattern2ZipEntry(fileNamePatternStr);
+      zipEntryFileNamePattern = new FileNamePattern(zipEntryFileNamePatternStr, context);
+    }
+
     if (timeBasedFileNamingAndTriggeringPolicy == null) {
       timeBasedFileNamingAndTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy<E>();
     }
@@ -95,6 +96,11 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     super.start();
   }
 
+  private String transformFileNamePattern2ZipEntry(String fileNamePatternStr) {
+    String slashified = FileFilterUtil.slashify(fileNamePatternStr);
+    return FileFilterUtil.afterLastSlash(slashified);
+  }
+
   public void setTimeBasedFileNamingAndTriggeringPolicy(
       TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering) {
     this.timeBasedFileNamingAndTriggeringPolicy = timeBasedTriggering;
@@ -112,15 +118,18 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     String elapsedPeriodsFileName = timeBasedFileNamingAndTriggeringPolicy
         .getElapsedPeriodsFileName();
 
+    String elpasedPeriodStem = FileFilterUtil.afterLastSlash(elapsedPeriodsFileName);
+
+
     if (compressionMode == CompressionMode.NONE) {
       if (getParentsRawFileProperty() != null) {
         renameUtil.rename(getParentsRawFileProperty(), elapsedPeriodsFileName);
       } // else { nothing to do if CompressionMode == NONE and parentsRawFileProperty == null }
     } else {
       if (getParentsRawFileProperty() == null) {
-        future = asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName);
+        future = asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName, elpasedPeriodStem);
       } else {
-        future = renamedRawAndAsyncCompress(elapsedPeriodsFileName);
+        future = renamedRawAndAsyncCompress(elapsedPeriodsFileName, elpasedPeriodStem);
       }
     }
 
@@ -129,18 +138,18 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     }
   }
 
-  Future asyncCompress(String nameOfFile2Compress, String nameOfCompressedFile)
+  Future asyncCompress(String nameOfFile2Compress, String nameOfCompressedFile, String innerEntryName)
       throws RolloverFailure {
     AsynchronousCompressor ac = new AsynchronousCompressor(compressor);
-    return ac.compressAsynchronously(nameOfFile2Compress, nameOfCompressedFile);
+    return ac.compressAsynchronously(nameOfFile2Compress, nameOfCompressedFile, innerEntryName);
   }
 
-  Future renamedRawAndAsyncCompress(String nameOfCompressedFile)
+  Future renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName)
       throws RolloverFailure {
     String parentsRawFile = getParentsRawFileProperty();
     String tmpTarget = parentsRawFile + System.nanoTime() + ".tmp";
     renameUtil.rename(parentsRawFile, tmpTarget);
-    return asyncCompress(tmpTarget, nameOfCompressedFile);
+    return asyncCompress(tmpTarget, nameOfCompressedFile, innerEntryName);
   }
 
   /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java
index 569221a..03af6fd 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java
@@ -25,10 +25,10 @@ public class AsynchronousCompressor {
   }
 
   public Future<?> compressAsynchronously(String nameOfFile2Compress,
-      String nameOfCompressedFile) {
+      String nameOfCompressedFile, String innerEntryName) {
     ExecutorService executor = Executors.newScheduledThreadPool(1);
     Future<?> future = executor.submit(new CompressionRunnable(compressor,
-        nameOfFile2Compress, nameOfCompressedFile));
+        nameOfFile2Compress, nameOfCompressedFile, innerEntryName));
     executor.shutdown();
     return future;
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java
index 425282f..8a0c54c 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java
@@ -18,16 +18,18 @@ public class CompressionRunnable implements Runnable {
 
   final Compressor compressor;
   final String nameOfFile2Compress;
-  final  String nameOfCompressedFile;
-  
+  final String nameOfCompressedFile;
+  final String innerEntryName;
+
   public CompressionRunnable(Compressor compressor, String nameOfFile2Compress,
-      String nameOfCompressedFile) {
+                             String nameOfCompressedFile, String innerEntryName) {
     this.compressor = compressor;
     this.nameOfFile2Compress = nameOfFile2Compress;
     this.nameOfCompressedFile = nameOfCompressedFile;
+    this.innerEntryName = innerEntryName;
   }
 
   public void run() {
-    compressor.compress(nameOfFile2Compress, nameOfCompressedFile);
+    compressor.compress(nameOfFile2Compress, nameOfCompressedFile, innerEntryName);
   }
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java
index cb2f899..2ecceb5 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java
@@ -39,7 +39,13 @@ public class Compressor extends ContextAwareBase {
     this.compressionMode = compressionMode;
   }
 
-  public void compress(String nameOfFile2Compress, String nameOfCompressedFile) {
+    /**
+     *
+     * @param nameOfFile2Compress
+     * @param nameOfCompressedFile
+     * @param innerEntryName The name of the file within the zip file. Use for ZIP compression.
+     */
+  public void compress(String nameOfFile2Compress, String nameOfCompressedFile, String innerEntryName) {
     switch (compressionMode) {
     case GZ:
       addInfo("GZ compressing [" + nameOfFile2Compress + "].");
@@ -47,7 +53,7 @@ public class Compressor extends ContextAwareBase {
       break;
     case ZIP:
       addInfo("ZIP compressing [" + nameOfFile2Compress + "].");
-      zipCompress(nameOfFile2Compress, nameOfCompressedFile);
+      zipCompress(nameOfFile2Compress, nameOfCompressedFile, innerEntryName);
       break;
     case NONE:
       throw new UnsupportedOperationException(
@@ -55,7 +61,7 @@ public class Compressor extends ContextAwareBase {
     }
   }
 
-  private void zipCompress(String nameOfFile2zip, String nameOfZippedFile) {
+  private void zipCompress(String nameOfFile2zip, String nameOfZippedFile, String innerEntryName) {
     File file2zip = new File(nameOfFile2zip);
 
     if (!file2zip.exists()) {
@@ -65,6 +71,11 @@ public class Compressor extends ContextAwareBase {
       return;
     }
 
+    if(innerEntryName == null) {
+      addStatus(new WarnStatus("The innerEntryName parameter cannot be null", this));
+      return;
+    }
+
     if (!nameOfZippedFile.endsWith(".zip")) {
       nameOfZippedFile = nameOfZippedFile + ".zip";
     }
@@ -83,7 +94,7 @@ public class Compressor extends ContextAwareBase {
       ZipOutputStream zos = new ZipOutputStream(fos);
       FileInputStream fis = new FileInputStream(nameOfFile2zip);
 
-      ZipEntry zipEntry = computeZipEntry(zippedFile);
+      ZipEntry zipEntry = computeZipEntry(innerEntryName);
       zos.putNextEntry(zipEntry);
 
       byte[] inbuf = new byte[8102];
@@ -112,7 +123,7 @@ public class Compressor extends ContextAwareBase {
   // Case 1: RawFile = null, Patern = foo-%d.zip
   // nestedFilename = foo-${current-date}
   //
-  // Case 2: RawFile = hello.txtm, Pattern = = foo-%d.zip
+  // Case 2: RawFile = hello.txt, Pattern = = foo-%d.zip
   // nestedFilename = foo-${current-date}
   //
   // in both cases, the strategy consisting of removing the compression
@@ -122,10 +133,15 @@ public class Compressor extends ContextAwareBase {
   // all having the same name, which could make it harder for the user
   // to unzip the file without collisions
   ZipEntry computeZipEntry(File zippedFile) {
-    String nameOfFileNestedWithinArchive = computeFileNameStr_WCS(zippedFile.getName(), compressionMode);
+    return computeZipEntry(zippedFile.getName());
+  }
+
+  ZipEntry computeZipEntry(String filename) {
+    String nameOfFileNestedWithinArchive = computeFileNameStr_WCS(filename, compressionMode);
     return new ZipEntry(nameOfFileNestedWithinArchive);
   }
 
+
   private void gzCompress(String nameOfFile2gz, String nameOfgzedFile) {
     File file2gz = new File(nameOfFile2gz);
 
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 353e992..3c7a82d 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
@@ -16,6 +16,7 @@ package ch.qos.logback.core.rolling.helper;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.pattern.DynamicConverter;
 
 /**
@@ -29,6 +30,7 @@ public class DateTokenConverter<E> extends DynamicConverter<E> implements MonoTy
    * The conversion word/character with which this converter is registered.
    */
   public final static String CONVERTER_KEY = "d";
+  public static final String DEFAULT_DATE_PATTERN = CoreConstants.DAILY_DATE_PATTERN;
 
   private String datePattern;
   private SimpleDateFormat sdf;
@@ -39,8 +41,7 @@ public class DateTokenConverter<E> extends DynamicConverter<E> implements MonoTy
   public void start() {
     this.datePattern = getFirstOption();
     if (this.datePattern == null) {
-      this.datePattern = "yyyy-MM-dd";
-      ;
+      this.datePattern = DEFAULT_DATE_PATTERN;
     }
     sdf = new SimpleDateFormat(datePattern);
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java
index 4522758..87f674b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java
@@ -42,8 +42,7 @@ public class DefaultArchiveRemover extends ContextAwareBase implements
       return true;
     }
     // if the literal string subsequent to the dtc contains a /, we also
-    // need
-    // parent cleaning
+    // need parent cleaning
 
     Converter<Object> p = fileNamePattern.headTokenConverter;
 
@@ -88,17 +87,17 @@ public class DefaultArchiveRemover extends ContextAwareBase implements
    * times.
    * 
    * @param dir
-   * @param recursivityCount
+   * @param depth
    */
-  void removeFolderIfEmpty(File dir, int recursivityCount) {
+  void removeFolderIfEmpty(File dir, int depth) {
     // we should never go more than 3 levels higher
-    if (recursivityCount >= 3) {
+    if (depth >= 3) {
       return;
     }
     if (dir.isDirectory() && FileFilterUtil.isEmptyDirectory(dir)) {
       addInfo("deleting folder [" + dir +"]");
       dir.delete();
-      removeFolderIfEmpty(dir.getParentFile(), recursivityCount + 1);
+      removeFolderIfEmpty(dir.getParentFile(), depth + 1);
     }
   }
 
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 0653905..4e76249 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
@@ -16,6 +16,8 @@ package ch.qos.logback.core.rolling;
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.List;
 
 import org.junit.After;
 import org.junit.Before;
@@ -126,7 +128,7 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
       rfa.doAppend(prefix+i);
     }
 
-    expectedFilenameList.add(randomOutputDir        + "a-sizeBased-smoke.log");
+    expectedFilenameList.add(randomOutputDir + "a-sizeBased-smoke.log");
     expectedFilenameList.add(randomOutputDir + "sizeBased-smoke.0");
     expectedFilenameList.add(randomOutputDir + "sizeBased-smoke.1");
     existenceCheck(expectedFilenameList);
@@ -174,7 +176,60 @@ public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
 
     existenceCheck(expectedFilenameList);
     reverseSortedContentCheck(randomOutputDir, runLength, prefix);
-  
   }
 
+  @Test
+  public void test3Zip() throws Exception {
+    Context context = new ContextBase();
+    RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
+    rfa.setEncoder(new EchoEncoder<Object>());
+    rfa.setContext(context);
+    rfa.setFile(randomOutputDir + "a-sbr-test3.log");
+
+    FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
+    fwrp.setContext(context);
+    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
+    sbtp.setContext(context);
+
+    sbtp.setMaxFileSize("100");
+    fwrp.setMinIndex(0);
+    // fwrp.setActiveFileName(Constants.TEST_DIR_PREFIX +
+    // "output/sbr-test3.log");
+    fwrp.setFileNamePattern(randomOutputDir + "sbr-test3.%i.zip");
+    fwrp.setParent(rfa);
+    fwrp.start();
+    rfa.setRollingPolicy(fwrp);
+    rfa.setTriggeringPolicy(sbtp);
+    rfa.start();
+
+    int runLength = 40;
+    String prefix = "hello";
+    for (int i = 0; i < runLength; i++) {
+      Thread.sleep(10);
+      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");
+
+    existenceCheck(expectedFilenameList);
+    reverseSortedContentCheck(randomOutputDir, runLength, prefix);
+    zipEntryNameCheck(expectedFilenameList);
+    //fail("we should check zipEntries names as well");
+
+  }
+
+  private void zipEntryNameCheck(List<String> expectedFilenameList) {
+    for(String filepath: expectedFilenameList) {
+      if(filepath.endsWith(".zip")) {
+        checkZipEntyName(filepath, "sbr-test3.%i.zip");
+      }
+    }
+  }
+
+  SimpleDateFormat SDF = new SimpleDateFormat();
+  private void checkZipEntyName(String filepath, String pattern) {
+      fail("to be continued");
+
+  }
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
index 759a2fa..e3f5ac1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
@@ -29,6 +29,8 @@ import java.util.concurrent.TimeoutException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.util.StatusPrinter;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -47,7 +49,6 @@ public class TimeBasedRollingWithArchiveRemovalTest {
   static final String MONTHLY_DATE_PATTERN = "yyyy-MM";
   static final String MONTHLY_CROLOLOG_DATE_PATTERN = "yyyy/MM";
 
-  static final String DAILY_DATE_PATTERN = "yyyy-MM-dd";
   static final String DAILY_CROLOLOG_DATE_PATTERN = "yyyy/MM/dd";
 
   static final long MILLIS_IN_MINUTE = 60 * 1000;
@@ -112,14 +113,15 @@ public class TimeBasedRollingWithArchiveRemovalTest {
         + "}/clean.txt.zip", MILLIS_IN_MONTH, maxHistory, numPeriods);
     int beginPeriod = Calendar.getInstance().get(Calendar.MONTH);
     boolean extraFolder = extraFolder(numPeriods, 12, beginPeriod, maxHistory);
+    StatusPrinter.print(context);
     check(expectedCountWithFolders(2, extraFolder));
   }
 
   @Test
   public void dailyRollover() throws Exception {
-    slashCount = computeSlashCount(DAILY_DATE_PATTERN);
+    slashCount = computeSlashCount(CoreConstants.DAILY_DATE_PATTERN);
     doRollover(
-        randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt.zip",
+        randomOutputDir + "clean-%d{" + CoreConstants.DAILY_DATE_PATTERN + "}.txt.zip",
         MILLIS_IN_DAY, 5, 5 * 3);
     check(expectedCountWithoutFolders(5));
   }
@@ -142,9 +144,9 @@ public class TimeBasedRollingWithArchiveRemovalTest {
     sizeAndTimeBasedFNATP.setMaxFileSize("10000");
     tbfnatp = sizeAndTimeBasedFNATP;
 
-    slashCount = computeSlashCount(DAILY_DATE_PATTERN);
+    slashCount = computeSlashCount(CoreConstants.DAILY_DATE_PATTERN);
     doRollover(
-        randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}-clean.%i.zip",
+        randomOutputDir + "/%d{" + CoreConstants.DAILY_DATE_PATTERN + "}-clean.%i.zip",
         MILLIS_IN_DAY, 5, 5 * 4);
 
     // make .zip optional so that if for one reason or another, no size-based
@@ -163,7 +165,7 @@ public class TimeBasedRollingWithArchiveRemovalTest {
 
     slashCount = 1;
     doRollover(
-        randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i.zip",
+        randomOutputDir + "/%d{" + CoreConstants.DAILY_DATE_PATTERN + "}/clean.%i.zip",
         MILLIS_IN_DAY, 5, 5 * 4);
     checkDirPatternCompliance(6);
   }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
index b69734d..f9e18c3 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
@@ -84,7 +84,7 @@ public class CompressTest {
     compressor.setContext(context);
     compressor.compress(CoreTestConstants.TEST_DIR_PREFIX
         + "input/compress1.txt", CoreTestConstants.OUTPUT_DIR_PREFIX
-        + "compress1.txt.gz");
+        + "compress1.txt.gz", null);
 
     StatusChecker checker = new StatusChecker(context);
     assertTrue(checker.isErrorFree());
@@ -99,7 +99,7 @@ public class CompressTest {
     compressor.setContext(context);
     compressor.compress(CoreTestConstants.TEST_DIR_PREFIX
         + "input/compress2.txt", CoreTestConstants.OUTPUT_DIR_PREFIX
-        + "compress2.txt");
+        + "compress2.txt", null);
 
     StatusChecker checker = new StatusChecker(context);
     assertTrue(checker.isErrorFree());
@@ -115,7 +115,7 @@ public class CompressTest {
     compressor.setContext(context);
     compressor.compress(CoreTestConstants.TEST_DIR_PREFIX
         + "input/compress3.txt", CoreTestConstants.OUTPUT_DIR_PREFIX
-        + "compress3.txt");
+        + "compress3.txt", "compress3.txt");
     StatusChecker checker = new StatusChecker(context);
     assertTrue(checker.isErrorFree());
 
diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java
index dd4143c..9126ced 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java
@@ -13,45 +13,61 @@
  */
 package ch.qos.logback.core.testUtil;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
+import java.io.*;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
 
 public class FileToBufferUtil {
 
   static public void readIntoList(File file, List<String> stringList)
-      throws IOException {
+          throws IOException {
 
-    if(file.getName().endsWith(".gz")) {
+    if (file.getName().endsWith(".gz")) {
       gzFileReadIntoList(file, stringList);
+    } else if (file.getName().endsWith(".zip")) {
+      zipFileReadIntoList(file, stringList);
+
     } else {
       regularReadIntoList(file, stringList);
     }
   }
-  
-  static public void regularReadIntoList(File file, List<String> stringList) throws IOException {
+
+  private static void zipFileReadIntoList(File file, List<String> stringList) throws IOException {
     FileInputStream fis = new FileInputStream(file);
-    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
+    ZipInputStream zin = new ZipInputStream(new BufferedInputStream(fis));
+    ZipFile zipFile = new ZipFile(file);
+    Enumeration entries = zipFile.entries();
+    ZipEntry entry = (ZipEntry) entries.nextElement();
+    readInputStream(zipFile.getInputStream(entry), stringList);
+  }
+
+  static void readInputStream(InputStream is, List<String> stringList) throws IOException {
+    BufferedReader in = new BufferedReader(new InputStreamReader(is));
     String line;
-    while( (line = in.readLine()) != null) {
+    while ((line = in.readLine()) != null) {
       stringList.add(line);
     }
     in.close();
   }
 
-  static public void gzFileReadIntoList(File file, List<String> stringList) throws IOException {
+  static public void regularReadIntoList(File file, List<String> stringList) throws IOException {
     FileInputStream fis = new FileInputStream(file);
-    GZIPInputStream gzis = new GZIPInputStream(fis);
-    BufferedReader in = new BufferedReader(new InputStreamReader(gzis));
+    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
     String line;
-    while( (line = in.readLine()) != null) {
+    while ((line = in.readLine()) != null) {
       stringList.add(line);
     }
     in.close();
   }
 
+  static public void gzFileReadIntoList(File file, List<String> stringList) throws IOException {
+    FileInputStream fis = new FileInputStream(file);
+    GZIPInputStream gzis = new GZIPInputStream(fis);
+    readInputStream(gzis, stringList);
+  }
+
 }

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

Summary of changes:
 .../java/ch/qos/logback/core/CoreConstants.java    |    1 +
 .../core/rolling/FixedWindowRollingPolicy.java     |   26 ++++++---
 .../logback/core/rolling/RollingPolicyBase.java    |    2 +
 ...TimeBasedFileNamingAndTriggeringPolicyBase.java |    4 -
 .../core/rolling/TimeBasedRollingPolicy.java       |   33 +++++++----
 .../rolling/helper/AsynchronousCompressor.java     |    4 +-
 .../core/rolling/helper/CompressionRunnable.java   |   10 ++-
 .../logback/core/rolling/helper/Compressor.java    |   28 +++++++--
 .../core/rolling/helper/DateTokenConverter.java    |    5 +-
 .../core/rolling/helper/DefaultArchiveRemover.java |   11 ++--
 .../logback/core/rolling/SizeBasedRollingTest.java |   59 +++++++++++++++++++-
 .../TimeBasedRollingWithArchiveRemovalTest.java    |   14 +++--
 .../logback/core/rolling/helper/CompressTest.java  |    6 +-
 .../logback/core/testUtil/FileToBufferUtil.java    |   46 ++++++++++-----
 14 files changed, 178 insertions(+), 71 deletions(-)


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


More information about the logback-dev mailing list