[logback-dev] branch, master, updated. feba37d06ec4fc8398641b3056f32e1afdcb0bb4

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Fri Nov 13 10:35:46 CET 2009


The branch, master has been updated
       via  feba37d06ec4fc8398641b3056f32e1afdcb0bb4 (commit)
      from  0334b5b0597eeb09a5319a00c69c1867a17b5b2f (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=feba37d06ec4fc8398641b3056f32e1afdcb0bb4
http://github.com/ceki/logback/commit/feba37d06ec4fc8398641b3056f32e1afdcb0bb4

commit feba37d06ec4fc8398641b3056f32e1afdcb0bb4
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Nov 13 10:35:51 2009 +0100

    Fixed http://jira.qos.ch/browse/LBCORE-98
    
    The name of the log file nested within .zip archives was incorrectly
    set to be that of the tmp file logback creates during
    compression. Anders Wallgren reported and posted an appropriate patch
    for this problem LBCORE-98.  The nested file is now named after the
    zip archive file. Analysis showed that this was an appropriate
    strategy in all the cases we considered.

diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
index 92a610e..cddef70 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
@@ -49,13 +49,13 @@ public class RollingFileAppender<E> extends FileAppender<E> {
       addWarn("For more information, please visit http://logback.qos.ch/codes.html#rfa_no_tp");
       return;
     }
-    
+
     // we don't want to void existing log files
-    if(!append) {
-      addWarn("Append mode is mandatory for RollingFileAppender");  
+    if (!append) {
+      addWarn("Append mode is mandatory for RollingFileAppender");
       append = true;
     }
-    
+
     if (rollingPolicy == null) {
       addError("No RollingPolicy was set for the RollingFileAppender named "
           + getName());
@@ -96,23 +96,11 @@ public class RollingFileAppender<E> extends FileAppender<E> {
   }
 
   /**
-   * Implements the usual roll over behaviour.
-   * 
-   * <p>If <code>MaxBackupIndex</code> is positive, then files {<code>File.1</code>,
-   * ..., <code>File.MaxBackupIndex -1</code>} are renamed to {<code>File.2</code>,
-   * ..., <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
-   * renamed <code>File.1</code> and closed. A new <code>File</code> is
-   * created to receive further log output.
-   * 
-   * <p>If <code>MaxBackupIndex</code> is equal to zero, then the
-   * <code>File</code> is truncated with no backup files created.
-   * 
+   * Implemented by delegating most of the rollover work to a rolling policy.
    */
   public synchronized void rollover() {
     // Note: This method needs to be synchronized because it needs exclusive
-    // acces while
-    // it closes and then re-opens the target file.
-
+    // access while it closes and then re-opens the target file.
     //
     // make sure to close the hereto active log file! Renaming under windows
     // does not work for open files.
@@ -130,7 +118,7 @@ public class RollingFileAppender<E> extends FileAppender<E> {
       // update the currentlyActiveFile
       // http://jira.qos.ch/browse/LBCORE-90
       currentlyActiveFile = new File(rollingPolicy.getActiveFileName());
-      
+
       // This will also close the file. This is OK since multiple
       // close operations are safe.
       this.openFile(rollingPolicy.getActiveFileName());
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 259d3a0..b987069 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
@@ -101,7 +101,7 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     return timeBasedTriggering;
   }
 
-  static String computeFileNameStr_WCS(String fileNamePatternStr,
+  static public String computeFileNameStr_WCS(String fileNamePatternStr,
       CompressionMode compressionMode) {
     int len = fileNamePatternStr.length();
     switch (compressionMode) {
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 2205091..4a620e2 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
@@ -20,11 +20,11 @@ import java.util.zip.GZIPOutputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
 import ch.qos.logback.core.spi.ContextAwareBase;
 import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.status.WarnStatus;
 
-
 /**
  * The <code>Compression</code> class implements ZIP and GZ file
  * compression/decompression methods.
@@ -34,24 +34,24 @@ import ch.qos.logback.core.status.WarnStatus;
 public class Compressor extends ContextAwareBase {
 
   final CompressionMode compressionMode;
-  //final String nameOfFile2Compress;
-  //final String nameOfCompressedFile;
 
+  // final String nameOfFile2Compress;
+  // final String nameOfCompressedFile;
 
   public Compressor(CompressionMode compressionMode) {
     this.compressionMode = compressionMode;
   }
-  
-  
-//  public Compressor(CompressionMode compressionMode, String nameOfFile2Compress, String nameOfCompressedFile) {
-//    this.compressionMode = compressionMode;
-//    //this.nameOfFile2Compress = nameOfFile2Compress;
-//    //this.nameOfCompressedFile = nameOfCompressedFile;
-//  }
-
-  public void compress( String nameOfFile2Compress, String nameOfCompressedFile) {
-    switch(compressionMode) {
-    case GZ: 
+
+  // public Compressor(CompressionMode compressionMode, String
+  // nameOfFile2Compress, String nameOfCompressedFile) {
+  // this.compressionMode = compressionMode;
+  // //this.nameOfFile2Compress = nameOfFile2Compress;
+  // //this.nameOfCompressedFile = nameOfCompressedFile;
+  // }
+
+  public void compress(String nameOfFile2Compress, String nameOfCompressedFile) {
+    switch (compressionMode) {
+    case GZ:
       addInfo("GZ compressing [" + nameOfFile2Compress + "].");
       gzCompress(nameOfFile2Compress, nameOfCompressedFile);
       break;
@@ -60,7 +60,8 @@ public class Compressor extends ContextAwareBase {
       zipCompress(nameOfFile2Compress, nameOfCompressedFile);
       break;
     case NONE:
-      throw new UnsupportedOperationException("compress method called in NONE compression mode");
+      throw new UnsupportedOperationException(
+          "compress method called in NONE compression mode");
     }
   }
 
@@ -68,9 +69,8 @@ public class Compressor extends ContextAwareBase {
     File file2zip = new File(nameOfFile2zip);
 
     if (!file2zip.exists()) {
-      addStatus(new WarnStatus(
-              "The file to compress named [" + nameOfFile2zip
-                  + "] does not exist.", this));
+      addStatus(new WarnStatus("The file to compress named [" + nameOfFile2zip
+          + "] does not exist.", this));
 
       return;
     }
@@ -82,9 +82,8 @@ public class Compressor extends ContextAwareBase {
     File zippedFile = new File(nameOfZippedFile);
 
     if (zippedFile.exists()) {
-      addStatus(new WarnStatus(
-          "The target compressed file named [" + nameOfZippedFile
-              + "] exist already.", this));
+      addStatus(new WarnStatus("The target compressed file named ["
+          + nameOfZippedFile + "] exist already.", this));
 
       return;
     }
@@ -94,7 +93,7 @@ public class Compressor extends ContextAwareBase {
       ZipOutputStream zos = new ZipOutputStream(fos);
       FileInputStream fis = new FileInputStream(nameOfFile2zip);
 
-      ZipEntry zipEntry = new ZipEntry(file2zip.getName());
+      ZipEntry zipEntry = computeZipEntry(zippedFile);
       zos.putNextEntry(zipEntry);
 
       byte[] inbuf = new byte[8102];
@@ -117,6 +116,27 @@ public class Compressor extends ContextAwareBase {
     }
   }
 
+  // http://jira.qos.ch/browse/LBCORE-98
+  // The name of the compressed file as nested within the zip archive
+  //
+  // Case 1: RawFile = null, Patern = foo-%d.zip
+  // nestedFilename = foo-${current-date}
+  //
+  // Case 2: RawFile = hello.txtm, Pattern = = foo-%d.zip
+  // nestedFilename = foo-${current-date}
+  //
+  // in both cases, the strategy consisting of removing the compression
+  // suffix of zip file works reasonably well. The alternative strategy
+  // whereby the nested file name was based on the value of the raw file name
+  // (applicable to case 2 only) has the disadvantage of the nested files
+  // 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 = TimeBasedRollingPolicy
+        .computeFileNameStr_WCS(zippedFile.getName(), compressionMode);
+    return new ZipEntry(nameOfFileNestedWithinArchive);
+  }
+
   private void gzCompress(String nameOfFile2gz, String nameOfgzedFile) {
     File file2gz = new File(nameOfFile2gz);
 
@@ -163,7 +183,7 @@ public class Compressor extends ContextAwareBase {
           + nameOfFile2gz + "] into [" + nameOfgzedFile + "].", this, e));
     }
   }
-  
+
   @Override
   public String toString() {
     return "c.q.l.core.rolling.helper.Compress";
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 0254ae2..953aabe 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -42,6 +42,10 @@
     by applying the relavant patch supplied by Hugues Malphettes.
     </p>
 
+    <p>Made the OSGi import declerations for Janino and javax optional
+    as proposed by David Varnes in <a
+    href="http://jira.qos.ch/browse/LBCORE-101">LBCORE-101</a>.</p>
+
     <p>JaninoEventEvaluator now passes the throwable associated with
     an event as a <code>java.lang.Throwable</code> instead of an
     <code>IThrowableProxy</code>. This fixes <a
@@ -50,6 +54,15 @@
     href="manual/filters.html#evalutatorFilter">EvaluatorFilter
     documentation</a> for more details.</p>
 
+    <p>The name of the log file nested within .zip archives was
+    incorrectly set to be that of the tmp file logback creates during
+    compression. Anders Wallgren reported and posted an appropriate
+    patch for this problem in <a
+    href="http://jira.qos.ch/browse/LBCORE-98">LBCORE-98</a>.  The
+    nested file is now named after the zip archive file. Analysis
+    showed that this was an appropriate strategy in all the cases we
+    considered.</p>
+
     <hr width="80%" align="center" />
 
     <h3>9th of August 2009 - Release of version 0.9.17</h3>

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

Summary of changes:
 .../logback/core/rolling/RollingFileAppender.java  |   26 ++------
 .../core/rolling/TimeBasedRollingPolicy.java       |    2 +-
 .../logback/core/rolling/helper/Compressor.java    |   66 +++++++++++++-------
 logback-site/src/site/pages/news.html              |   13 ++++
 4 files changed, 64 insertions(+), 43 deletions(-)


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


More information about the logback-dev mailing list