[logback-dev] branch, master, updated. 0908ef4dc8bebd0c8f38dbdd4c2d0282a01d77fb

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Sat Nov 28 23:44:38 CET 2009


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

commit 0908ef4dc8bebd0c8f38dbdd4c2d0282a01d77fb
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Sat Nov 28 23:36:03 2009 +0100

    - Partial fix to LBGENERAL-35

diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java
index 6ad9bd7..ef19d9d 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java
@@ -32,6 +32,7 @@ public class DefaultTimeBasedFileNamingAndTriggeringPolicy<E> extends TimeBasedF
   public void start() {
     super.start();
     archiveRemover = new DefaultArchiveRemover(tbrp.fileNamePattern, rc);
+    archiveRemover.setContext(context);
     started = true;
   }
   
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java
index 53cf5f7..a8b5c10 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java
@@ -15,12 +15,14 @@ package ch.qos.logback.core.rolling.helper;
 
 import java.util.Date;
 
+import ch.qos.logback.core.spi.ContextAware;
+
 /**
  * Given a date remove older archived log files.
  * 
  * @author Ceki G&uuml;lc&uuml;
  */
-public interface ArchiveRemover {
+public interface ArchiveRemover extends ContextAware {
   public void clean(Date now);
   public void setMaxHistory(int maxHistory);
 } 
\ No newline at end of file
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 c18b53c..32e7e56 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
@@ -18,8 +18,10 @@ import java.util.Date;
 
 import ch.qos.logback.core.pattern.Converter;
 import ch.qos.logback.core.pattern.LiteralConverter;
+import ch.qos.logback.core.spi.ContextAwareBase;
 
-public class DefaultArchiveRemover implements ArchiveRemover {
+public class DefaultArchiveRemover extends ContextAwareBase implements
+    ArchiveRemover {
 
   final FileNamePattern fileNamePattern;
   final RollingCalendar rc;
@@ -36,32 +38,33 @@ public class DefaultArchiveRemover implements ArchiveRemover {
   boolean computeParentCleaningFlag(FileNamePattern fileNamePattern) {
     DateTokenConverter dtc = fileNamePattern.getDateTokenConverter();
     // if the date pattern has a /, then we need parent cleaning
-    if(dtc.getDatePattern().indexOf('/') != -1) {
+    if (dtc.getDatePattern().indexOf('/') != -1) {
       return true;
     }
-    // if the literal string subsequent to the dtc contains a /, we also need
+    // if the literal string subsequent to the dtc contains a /, we also
+    // need
     // parent cleaning
-    
+
     Converter<Object> p = fileNamePattern.headTokenConverter;
-    
+
     // find the date converter
-    while(p != null) {
-      if(p instanceof DateTokenConverter) {
+    while (p != null) {
+      if (p instanceof DateTokenConverter) {
         break;
       }
       p = p.getNext();
     }
-    
-    while(p != null) {
-      if(p instanceof LiteralConverter) {
+
+    while (p != null) {
+      if (p instanceof LiteralConverter) {
         String s = p.convert(null);
-        if(s.indexOf('/') != -1) {
+        if (s.indexOf('/') != -1) {
           return true;
         }
       }
       p = p.getNext();
     }
-    
+
     // no /, so we don't need parent cleaning
     return false;
   }
@@ -72,6 +75,7 @@ public class DefaultArchiveRemover implements ArchiveRemover {
     File file2Delete = new File(filename);
     if (file2Delete.exists() && file2Delete.isFile()) {
       file2Delete.delete();
+      addInfo("deleting " + file2Delete);
       if (parentClean) {
         removeFolderIfEmpty(file2Delete.getParentFile(), 0);
       }
@@ -92,6 +96,7 @@ public class DefaultArchiveRemover implements ArchiveRemover {
       return;
     }
     if (dir.isDirectory() && FileFilterUtil.isEmptyDirectory(dir)) {
+      addInfo("deleting folder [" + dir +"]");
       dir.delete();
       removeFolderIfEmpty(dir.getParentFile(), recursivityCount + 1);
     }
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 4d1d697..2d3dcd4 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
@@ -35,6 +35,7 @@ import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.layout.EchoLayout;
 import ch.qos.logback.core.testUtil.RandomUtil;
 import ch.qos.logback.core.util.CoreTestConstants;
+import ch.qos.logback.core.util.StatusPrinter;
 
 public class TimeBasedRollingWithArchiveRemovalTest {
 
@@ -109,6 +110,7 @@ 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));
   }
 
@@ -279,7 +281,8 @@ public class TimeBasedRollingWithArchiveRemovalTest {
   // year is 2012, and not 2013 (the current year).
   boolean extraFolder(int numPeriods, int periodsPerEra, int beginPeriod,
       int maxHistory) {
-    int remainder = (beginPeriod + numPeriods) % periodsPerEra;
+	int adjustedBegin =   beginPeriod+1;
+    int remainder = ((adjustedBegin) + numPeriods) % periodsPerEra;
     return (remainder < maxHistory + 1);
   }
 

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

Summary of changes:
 ...aultTimeBasedFileNamingAndTriggeringPolicy.java |    1 +
 .../core/rolling/helper/ArchiveRemover.java        |    4 ++-
 .../core/rolling/helper/DefaultArchiveRemover.java |   29 +++++++++++--------
 .../TimeBasedRollingWithArchiveRemovalTest.java    |    5 +++-
 4 files changed, 25 insertions(+), 14 deletions(-)


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


More information about the logback-dev mailing list