com.credibledoc.substitution.reporting.logback.StartupTriggeringPolicy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of substitution-reporting Show documentation
Show all versions of substitution-reporting Show documentation
This library serves for reports creation. These reports can describe
a structure and behavior of some application or system.
See the https://github.com/credibledoc/credible-doc/tree/master/substitution/substitution-reporting page.
package com.credibledoc.substitution.reporting.logback;
import ch.qos.logback.core.rolling.TriggeringPolicyBase;
import java.io.File;
/**
* The {@link TriggeringPolicyBase} that triggered on startup when the previous file is not empty.
*
* @param this event not used in the trigger logic
*
* @author Kyrylo Semenko
*/
public class StartupTriggeringPolicy extends TriggeringPolicyBase {
private boolean isTriggeringEvent = true;
/**
* Return 'true' when the application launched.
* @param activeFile is used for the decision
* @param event is not used
* @return Return 'true' at first time. Then return 'false'.
*/
public boolean isTriggeringEvent(final File activeFile, final E event) {
if (isTriggeringEvent) {
isTriggeringEvent = false;
// Without this condition a zero - length file has been created next to the activeFile
return activeFile.length() > 0;
}
return false;
}
}