Package edu.wisc.ssec.mcidasv.util
Class TailFriendlyRollingPolicy<E>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.rolling.RollingPolicyBase
ch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>
edu.wisc.ssec.mcidasv.util.TailFriendlyRollingPolicy<E>
- All Implemented Interfaces:
ch.qos.logback.core.rolling.RollingPolicy
,ch.qos.logback.core.rolling.TriggeringPolicy<E>
,ch.qos.logback.core.spi.ContextAware
,ch.qos.logback.core.spi.LifeCycle
public class TailFriendlyRollingPolicy<E>
extends ch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>
This Logback "rolling policy" copies the contents of a log file
(in this case, mcidasv.log) to the specified destination, and then
"zeroes out" the original log file. This approach allows McIDAS-V
users to run a command like "tail -f mcidasv.log" without any
issue. Even on Windows.
-
Field Summary
FieldsFields inherited from class ch.qos.logback.core.rolling.TimeBasedRollingPolicy
totalSizeCap
Fields inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
compressionMode, fileNamePatternStr
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Future
<?> asyncCompress
(String uncompressedPath, String compressedPath, String innerEntryName) private static boolean
isFileEmpty
(String filepath) Determine if the file at the given path is zero length.void
renameByCopying
(String src, String target) Copies the contents ofsrc
intotarget
, and then "zeroes out"src
.(package private) Future
<?> renamedRawAndAsyncCompress
(String nameOfCompressedFile, String innerEntryName) void
rollover()
Methods inherited from class ch.qos.logback.core.rolling.TimeBasedRollingPolicy
getActiveFileName, getLengthCounter, getMaxHistory, getTimeBasedFileNamingAndTriggeringPolicy, isCleanHistoryOnStart, isTriggeringEvent, isUnboundedTotalSizeCap, setCleanHistoryOnStart, setMaxHistory, setTimeBasedFileNamingAndTriggeringPolicy, setTotalSizeCap, start, stop, toString
Methods inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
adjustCompressionModeAndFileNamePatternStrIfNecessary, determineCompressionMode, getCompressionMode, getFileNamePattern, getParentsRawFileProperty, isParentPrudent, isStarted, setFileNamePattern, setParent
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.qos.logback.core.spi.LifeCycle
isStarted
-
Field Details
-
future
-
-
Constructor Details
-
TailFriendlyRollingPolicy
public TailFriendlyRollingPolicy()
-
-
Method Details
-
rollover
- Specified by:
rollover
in interfacech.qos.logback.core.rolling.RollingPolicy
- Overrides:
rollover
in classch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>
- Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
asyncCompress
Future<?> asyncCompress(String uncompressedPath, String compressedPath, String innerEntryName) throws ch.qos.logback.core.rolling.RolloverFailure - Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
renamedRawAndAsyncCompress
Future<?> renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName) throws ch.qos.logback.core.rolling.RolloverFailure - Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
renameByCopying
public void renameByCopying(String src, String target) throws ch.qos.logback.core.rolling.RolloverFailure Copies the contents ofsrc
intotarget
, and then "zeroes out"src
.- Parameters:
src
- Path to the file to be copied. Cannot benull
.target
- Path to the destination file. Cannot benull
.- Throws:
ch.qos.logback.core.rolling.RolloverFailure
- if copying failed.
-
isFileEmpty
Determine if the file at the given path is zero length.- Parameters:
filepath
- Path to the file to be tested. Cannot benull
.- Returns:
true
iffilepath
exists and is empty.
-