View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.rolling;
15  
16  import ch.qos.logback.core.rolling.helper.ArchiveRemover;
17  import ch.qos.logback.core.spi.ContextAware;
18  
19  /**
20   * This interface lists the set of methods that need to be implemented by
21   * triggering policies which are nested within a {@link TimeBasedRollingPolicy}.
22   * 
23   * @author Ceki Gülcü
24   * 
25   * @param <E>
26   */
27  public interface TimeBasedFileNamingAndTriggeringPolicy<E> extends
28      TriggeringPolicy<E>, ContextAware {
29  
30    /**
31     * Set the host/parent {@link TimeBasedRollingPolicy}.
32     * 
33     * @param tbrp
34     *                parent TimeBasedRollingPolicy
35     */
36    void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> tbrp);
37  
38    /**
39     * Return the file name for the elapsed periods file name.
40     * 
41     * @return
42     */
43    String getElapsedPeriodsFileName();
44  
45    /**
46     * Return the current periods file name without the compression suffix. This
47     * value is equivalent to the active file name.
48     * 
49     * @return current period's file name (without compression suffix)
50     */
51    String getCurrentPeriodsFileNameWithoutCompressionSuffix();
52  
53    /**
54     * Return the archive remover appropriate for this instance.
55     */
56    ArchiveRemover getArchiveRemover();
57    
58    /**
59     * Return the current time which is usually the value returned by
60     * System.currentMillis(). However, for <b>testing</b> purposed this value
61     * may be different than the real time.
62     * 
63     * @return current time value
64     */
65    long getCurrentTime();
66  
67    /**
68     * Set the current time. Only unit tests should invoke this method.
69     * 
70     * @param now
71     */
72    void setCurrentTime(long now);
73  
74    /**
75     * Set some date in the current period. Only unit tests should invoke this
76     * method.
77     * 
78     * WARNING: method removed. A unit test should not set the
79     * date in current period. It is the job of the FNATP to compute that.
80     * 
81     * @param date
82     */
83    //void setDateInCurrentPeriod(Date date); 
84  }