001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.rolling;
015
016import ch.qos.logback.core.FileAppender;
017import ch.qos.logback.core.rolling.helper.CompressionMode;
018import ch.qos.logback.core.spi.LifeCycle;
019
020/**
021 * A <code>RollingPolicy</code> is responsible for performing the rolling over
022 * of the active log file. The <code>RollingPolicy</code> is also responsible
023 * for providing the <em>active log file</em>, that is the live file where
024 * logging output will be directed.
025 * 
026 * @author Ceki G&uuml;lc&uuml;
027 */
028public interface RollingPolicy extends LifeCycle {
029
030    /**
031     * Rolls over log files according to implementation policy.
032     * 
033     * <p>This method is invoked by {@link RollingFileAppender}, usually at the
034     * behest of its {@link TriggeringPolicy}.
035     * 
036     * @throws RolloverFailure
037     *                 Thrown if the rollover operation fails for any reason.
038     */
039    void rollover() throws RolloverFailure;
040
041    /**
042     * Get the name of the active log file.
043     * 
044     * <p>With implementations such as {@link TimeBasedRollingPolicy}, this
045     * method returns a new file name, where the actual output will be sent.
046     * 
047     * <p>On other implementations, this method might return the FileAppender's
048     * file property.
049     */
050    String getActiveFileName();
051
052    /**
053     * The compression mode for this policy.
054     * 
055     * @return
056     */
057    CompressionMode getCompressionMode();
058
059    /**
060     * This method allows RollingPolicy implementations to be aware of their
061     * containing appender.
062     * 
063     * @param appender
064     */
065
066    void setParent(FileAppender<?> appender);
067}