[logback-dev] svn commit: r844 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling

noreply.seb at qos.ch noreply.seb at qos.ch
Wed Nov 1 14:34:55 CET 2006


Author: seb
Date: Wed Nov  1 14:34:54 2006
New Revision: 844

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java

Log:
Changed getActiveFileName() method name to getNewActiveFileName()
Other minor fixes

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java	Wed Nov  1 14:34:54 2006
@@ -83,7 +83,7 @@
       throw new IllegalStateException(FNP_NOT_SET + SEE_FNP_NOT_SET);
     }
     // if (activeFileName == null) {
-    if (getActiveFileName() == null) {
+    if (getNewActiveFileName() == null) {
       addWarn("The ActiveFile name option must be set before using this rolling policy.");
       throw new IllegalStateException("The ActiveFileName option must be set.");
     }
@@ -137,13 +137,13 @@
       // move active file name to min
       switch (compressionMode) {
       case Compress.NONE:
-        util.rename(getActiveFileName(), fileNamePattern.convertInt(minIndex));
+        util.rename(getNewActiveFileName(), fileNamePattern.convertInt(minIndex));
         break;
       case Compress.GZ:
-        compress.GZCompress(getActiveFileName(), fileNamePattern.convertInt(minIndex));
+        compress.GZCompress(getNewActiveFileName(), fileNamePattern.convertInt(minIndex));
         break;
       case Compress.ZIP:
-        compress.ZIPCompress(getActiveFileName(), fileNamePattern.convertInt(minIndex));
+        compress.ZIPCompress(getNewActiveFileName(), fileNamePattern.convertInt(minIndex));
         break;
       }
     }
@@ -154,7 +154,7 @@
    * 
    * @see {@link setActiveFileName}.
    */
-  public String getActiveFileName() {
+  public String getNewActiveFileName() {
     return getParentFileName();
   }
 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java	Wed Nov  1 14:34:54 2006
@@ -82,7 +82,7 @@
       //if no active file name was set, then it's the responsability of the
       //rollingPolicy to create one.
       if (getFile() == null) {
-        setFile(rollingPolicy.getActiveFileName());
+        setFile(rollingPolicy.getNewActiveFileName());
       }
       
       activeFileCache = new File(getFile());

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java	Wed Nov  1 14:34:54 2006
@@ -12,33 +12,46 @@
 import ch.qos.logback.core.FileAppender;
 import ch.qos.logback.core.spi.LifeCycle;
 
-
-
 /**
- * A <code>RollingPolicy</code> is responsible for performing the
- * rolling over of the active log file. The <code>RollingPolicy</code>
- * is also responsible for providing the <em>active log file</em>,
- * that is the live file where logging output will be directed.
+ * A <code>RollingPolicy</code> is responsible for performing the rolling over
+ * of the active log file. The <code>RollingPolicy</code> is also responsible
+ * for providing the <em>active log file</em>, that is the live file where
+ * logging output will be directed.
  * 
  * @author Ceki G&uuml;lc&uuml;
- * */
+ */
 public interface RollingPolicy extends LifeCycle {
-  
+
   /**
-   * Rolls over log files according to implementation policy.  
+   * Rolls over log files according to implementation policy.
+   * <p>
    * <p>
-   * <p>This method is invoked by {@link RollingFileAppender}, usually 
-   * at the behest of its {@link TriggeringPolicy}.
+   * This method is invoked by {@link RollingFileAppender}, usually at the
+   * behest of its {@link TriggeringPolicy}.
    * 
-   * @throws RolloverFailure Thrown if the rollover operation fails for any
-   * reason.
+   * @throws RolloverFailure
+   *           Thrown if the rollover operation fails for any reason.
    */
   public void rollover() throws RolloverFailure;
 
   /**
    * Get the new name of the active log file.
-   * */  
-  public String getActiveFileName();
+   * With implementations such as {@link TimeBasedRollingPolicy}, 
+   * this method returns a new file name, where the actual output
+   * will be sent.
+   * 
+   * On some implementations, this method might return
+   * the FileAppender's file attribute.
+   */
+  public String getNewActiveFileName();
+
+  
+  /**
+   * This method allows RollingPolicy implementations
+   * to be aware of their containing appender.
+   * 
+   * @param appender
+   */
   
   public void setParent(FileAppender appender);
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	Wed Nov  1 14:34:54 2006
@@ -249,9 +249,7 @@
     //if we already generated a name, then we have to update
     //the fileAppender with a new active file name.
     if (getParentFileName() == lastGeneratedFileName) {
-      String newFile = activeFileNamePattern.convertDate(lastCheck);
-      setParentFileName(newFile);
-      lastGeneratedFileName = newFile;
+      setParentFileName(getNewActiveFileName());
     }
   }
 
@@ -280,7 +278,7 @@
    * and only if the parent file name is null, so no test is required.
    *
    */
-  public String getActiveFileName() {
+  public String getNewActiveFileName() {
     String newName = activeFileNamePattern.convertDate(lastCheck);
     addInfo("Generated a new name for RollingFileAppender: " + newName);
     lastGeneratedFileName = newName;



More information about the logback-dev mailing list