Class PatternProcessor
java.lang.Object
org.apache.logging.log4j.core.appender.rolling.PatternProcessor
Parses the rollover pattern.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private static final char[]
private final FileExtension
private RolloverFrequency
private static final char[]
private boolean
private static final String
protected static final Logger
private static final char
private static final char
private static final char
private long
private final String
private final ArrayPatternConverter[]
private final FormattingInfo[]
private long
private static final char
private static final char[]
private static final char
-
Constructor Summary
ConstructorsConstructorDescriptionPatternProcessor
(String pattern) Constructor.PatternProcessor
(String pattern, PatternProcessor copy) Copy constructor with another pattern as source. -
Method Summary
Modifier and TypeMethodDescriptionprivate RolloverFrequency
calculateFrequency
(String pattern) private PatternParser
private long
debugGetNextTime
(long nextTime) private String
format
(long time) final void
formatFileName
(StringBuilder buf, boolean useCurrentTime, Object obj) Format file name.protected final void
formatFileName
(StringBuilder buf, Object... objects) Formats file name.final void
formatFileName
(StrSubstitutor subst, StringBuilder buf, boolean useCurrentTime, Object obj) Formats file name.final void
formatFileName
(StrSubstitutor subst, StringBuilder buf, Object obj) Formats file name.long
long
long
getNextTime
(long currentMillis, int increment, boolean modulus) Returns the next potential rollover time.long
private void
private boolean
patternContains
(String pattern, char character) private boolean
patternContains
(String pattern, char... chars) void
setCurrentFileTime
(long currentFileTime) void
setPrevFileTime
(long prevFileTime) void
setTimeBased
(boolean isTimeBased) toString()
void
-
Field Details
-
LOGGER
-
KEY
- See Also:
-
YEAR_CHAR
private static final char YEAR_CHAR- See Also:
-
MONTH_CHAR
private static final char MONTH_CHAR- See Also:
-
WEEK_CHARS
private static final char[] WEEK_CHARS -
DAY_CHARS
private static final char[] DAY_CHARS -
HOUR_CHARS
private static final char[] HOUR_CHARS -
MINUTE_CHAR
private static final char MINUTE_CHAR- See Also:
-
SECOND_CHAR
private static final char SECOND_CHAR- See Also:
-
MILLIS_CHAR
private static final char MILLIS_CHAR- See Also:
-
patternConverters
-
patternFields
-
fileExtension
-
prevFileTime
private long prevFileTime -
nextFileTime
private long nextFileTime -
currentFileTime
private long currentFileTime -
isTimeBased
private boolean isTimeBased -
frequency
-
pattern
-
-
Constructor Details
-
PatternProcessor
Constructor.- Parameters:
pattern
- The file pattern.
-
PatternProcessor
Copy constructor with another pattern as source.- Parameters:
pattern
- The file pattern.copy
- Source pattern processor
-
-
Method Details
-
getPattern
-
toString
-
setTimeBased
public void setTimeBased(boolean isTimeBased) -
getCurrentFileTime
public long getCurrentFileTime() -
setCurrentFileTime
public void setCurrentFileTime(long currentFileTime) -
getPrevFileTime
public long getPrevFileTime() -
setPrevFileTime
public void setPrevFileTime(long prevFileTime) -
getFileExtension
-
getNextTime
public long getNextTime(long currentMillis, int increment, boolean modulus) Returns the next potential rollover time.- Parameters:
currentMillis
- The current time.increment
- The increment to the next time.modulus
- If true the time will be rounded to occur on a boundary aligned with the increment.- Returns:
- the next potential rollover time and the timestamp for the target file.
-
updateTime
public void updateTime() -
debugGetNextTime
private long debugGetNextTime(long nextTime) -
format
-
increment
-
formatFileName
Format file name.- Parameters:
buf
- string buffer to which formatted file name is appended, may not be null.obj
- object to be evaluated in formatting, may not be null.
-
formatFileName
Formats file name.- Parameters:
subst
- The StrSubstitutor.buf
- string buffer to which formatted file name is appended, may not be null.obj
- object to be evaluated in formatting, may not be null.
-
formatFileName
public final void formatFileName(StrSubstitutor subst, StringBuilder buf, boolean useCurrentTime, Object obj) Formats file name.- Parameters:
subst
- The StrSubstitutor.buf
- string buffer to which formatted file name is appended, may not be null.obj
- object to be evaluated in formatting, may not be null.
-
formatFileName
Formats file name.- Parameters:
buf
- string buffer to which formatted file name is appended, may not be null.objects
- objects to be evaluated in formatting, may not be null.
-
calculateFrequency
-
createPatternParser
-
patternContains
-
patternContains
-
getFrequency
-
getNextFileTime
public long getNextFileTime()
-