[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-8-gbe9513c

Gitbot git-noreply at pixie.qos.ch
Wed Nov 2 18:24:41 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  be9513c71eb0ed9869f6269b01dd0151c114a169 (commit)
      from  518594a3755cd35892a01a235932de56c7e2b898 (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=be9513c71eb0ed9869f6269b01dd0151c114a169
http://github.com/ceki/logback/commit/be9513c71eb0ed9869f6269b01dd0151c114a169

commit be9513c71eb0ed9869f6269b01dd0151c114a169
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Nov 2 18:24:14 2011 +0100

    started working on LBCORE-226

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 1a90833..0981f1f 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
@@ -33,7 +33,7 @@ import ch.qos.logback.core.rolling.helper.*;
 public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     TriggeringPolicy<E> {
   static final String FNP_NOT_SET = "The FileNamePattern option must be set before using TimeBasedRollingPolicy. ";
-  static final int NO_DELETE_HISTORY = 0;
+  static final int INFINITE_HISTORY = 0;
 
   // WCS: without compression suffix
   FileNamePattern fileNamePatternWCS;
@@ -42,11 +42,13 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
   private RenameUtil renameUtil = new RenameUtil();
   Future<?> future;
 
-  private int maxHistory = NO_DELETE_HISTORY;
+  private int maxHistory = INFINITE_HISTORY;
   private ArchiveRemover archiveRemover;
 
   TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedFileNamingAndTriggeringPolicy;
 
+  boolean cleanHistoryOnStart = false;
+
   public void start() {
     // set the LR for our utility object
     renameUtil.setContext(this.context);
@@ -87,9 +89,12 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     // the maxHistory property is given to TimeBasedRollingPolicy instead of to
     // the TimeBasedFileNamingAndTriggeringPolicy. This makes it more convenient
     // for the user at the cost of inconsistency here.
-    if (maxHistory != NO_DELETE_HISTORY) {
+    if (maxHistory != INFINITE_HISTORY) {
       archiveRemover = timeBasedFileNamingAndTriggeringPolicy.getArchiveRemover();
       archiveRemover.setMaxHistory(maxHistory);
+      if(cleanHistoryOnStart) {
+        archiveRemover.clean(new Date(timeBasedFileNamingAndTriggeringPolicy.getCurrentTime()));
+      }
     }
 
     super.start();
@@ -204,6 +209,21 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
     this.maxHistory = maxHistory;
   }
 
+
+  public boolean isCleanHistoryOnStart() {
+    return cleanHistoryOnStart;
+  }
+
+  /**
+   * Should archive removal be attempted on application start up? Default is false.
+   * @since 1.0.1
+   * @param cleanHistoryOnStart
+   */
+  public void setCleanHistoryOnStart(boolean cleanHistoryOnStart) {
+    this.cleanHistoryOnStart = cleanHistoryOnStart;
+  }
+
+
   @Override
   public String toString() {
     return "c.q.l.core.rolling.TimeBasedRollingPolicy";

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

Summary of changes:
 .../core/rolling/TimeBasedRollingPolicy.java       |   26 +++++++++++++++++--
 1 files changed, 23 insertions(+), 3 deletions(-)


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


More information about the logback-dev mailing list