View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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 TriggeringPolicy<E>, ContextAware {
28  
29      /**
30       * Set the host/parent {@link TimeBasedRollingPolicy}.
31       * 
32       * @param tbrp
33       *                parent TimeBasedRollingPolicy
34       */
35      void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> tbrp);
36  
37      /**
38       * Return the file name for the elapsed periods file name.
39       * 
40       * @return
41       */
42      String getElapsedPeriodsFileName();
43  
44      /**
45       * Return the current periods file name without the compression suffix. This
46       * value is equivalent to the active file name.
47       * 
48       * @return current period's file name (without compression suffix)
49       */
50      String getCurrentPeriodsFileNameWithoutCompressionSuffix();
51  
52      /**
53       * Return the archive remover appropriate for this instance.
54       */
55      ArchiveRemover getArchiveRemover();
56  
57      /**
58       * Return the current time which is usually the value returned by
59       * System.currentMillis(). However, for <b>testing</b> purposed this value
60       * may be different than the real time.
61       * 
62       * @return current time value
63       */
64      long getCurrentTime();
65  
66      /**
67       * Set the current time. Only unit tests should invoke this method.
68       * 
69       * @param now
70       */
71      void setCurrentTime(long now);
72  
73      /**
74       * Set some date in the current period. Only unit tests should invoke this
75       * method.
76       * 
77       * WARNING: method removed. A unit test should not set the
78       * date in current period. It is the job of the FNATP to compute that.
79       * 
80       * @param date
81       */
82      // void setDateInCurrentPeriod(Date date);
83  }