Package org.jboss.logmanager.formatters
Class Formatters
- java.lang.Object
-
- org.jboss.logmanager.formatters.Formatters
-
public final class Formatters extends java.lang.ObjectFormatter utility methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFormatters.JustifyingFormatStep(package private) static classFormatters.Segmentprivate static classFormatters.SegmentedFormatStep
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEFAULT_TRUNCATE_BEGINNINGprivate static java.lang.StringNEW_LINEprivate static java.util.logging.FormatterNULL_FORMATTERprivate static java.util.regex.PatternPRECISION_INT_PATTERNprivate static java.lang.StringseparatorStringstatic java.lang.StringTHREAD_ID
-
Constructor Summary
Constructors Modifier Constructor Description privateFormatters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringapplySegments(int count, java.lang.String subject)Apply up tocounttrailing segments of the given string to the givenbuilder.private static java.lang.StringapplySegments(java.lang.String precision, java.lang.String subject)Apply up toprecisiontrailing segments of the given string to the givenbuilder.static FormatStepclassNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String precision)Create a format step which emits the source class name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatStepclassNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, java.lang.String precision)Create a format step which emits the source class name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatStepdateFormatStep(java.lang.String formatString, boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the date of the log record with the given justification rules.static FormatStepdateFormatStep(java.util.TimeZone timeZone, java.lang.String formatString, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the date of the log record with the given justification rules.static FormatStepdateFormatStep(java.util.TimeZone timeZone, java.lang.String formatString, boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the date of the log record with the given justification rules.static FormatStepexceptionFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String argument, boolean extended)Create a format step which emits the stack trace of an exception with the given justification rules.static FormatStepexceptionFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, boolean extended)Create a format step which emits the stack trace of an exception with the given justification rules.static FormatStepfileNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the source file name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatStepfileNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the source file name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).private static java.lang.StringfindHostname(java.util.Properties props, java.util.Map<java.lang.String,java.lang.String> env, boolean qualified)private static java.lang.StringfindQualifiedHostname(java.util.Properties props, java.util.Map<java.lang.String,java.lang.String> env)static FormatStepformatColor(ColorMap colors, java.lang.String color)(package private) static java.lang.StringgetJarName(java.net.URL resource, java.lang.String classResourceName)static FormatStephostnameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, boolean qualified)Create a format step which emits the hostname.static FormatSteplevelFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the log level name.static FormatSteplevelFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the log level name.static FormatSteplineNumberFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the source file line number with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatSteplineNumberFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the source file line number with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatSteplineSeparatorFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the platform line separator.static FormatSteplineSeparatorFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the platform line separator.static FormatSteplocalizedLevelFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the localized log level name.static FormatSteplocalizedLevelFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the localized log level name.static FormatSteplocationInformationFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the complete source location information with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatSteplocationInformationFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the complete source location information with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatSteploggerNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String precision)Create a format step which emits the logger name with the given justification rules.static FormatSteploggerNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, java.lang.String precision)Create a format step which emits the logger name with the given justification rules.static FormatStepmdcFormatStep(java.lang.String key, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the MDC value associated with the given key of the log record.static FormatStepmdcFormatStep(java.lang.String key, boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the MDC value associated with the given key of the log record.static FormatStepmessageFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the formatted log message text with the given justification rules.static FormatStepmessageFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the formatted log message text with the given justification rules.static FormatStepmethodNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the source method name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatStepmethodNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the source method name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).static FormatStepndcFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, int count)Create a format step which emits the NDC value of the log record.static FormatStepndcFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the NDC value of the log record.static java.util.logging.FormatternullFormatter()Get the null formatter, which outputs nothing.(package private) static java.util.Deque<java.lang.String>parseCategorySegments(java.lang.String category)(package private) static java.util.Map<java.lang.Integer,Formatters.Segment>parsePatternSegments(java.lang.String pattern)static FormatSteprelativeTimeFormatStep(long baseTime, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the number of milliseconds since the given base time.static FormatSteprelativeTimeFormatStep(long baseTime, boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the number of milliseconds since the given base time.static FormatStepresourceKeyFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the log message resource key (if any) with the given justification rules.static FormatStepresourceKeyFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the log message resource key (if any) with the given justification rules.static FormatStepsimpleMessageFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the formatted log message text (simple version, no exception traces) with the given justification rules.static FormatStepsimpleMessageFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the formatted log message text (simple version, no exception traces) with the given justification rules.static FormatStepsystemPropertyFormatStep(java.lang.String argument, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits a system property value associated with the given key.static FormatSteptextFormatStep(java.lang.String string)Create a format step which simply emits the given string.static FormatStepthreadFormatStep(java.lang.String argument, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the id ifidis passed as the argument, otherwise the the thread name is used.static FormatStepthreadIdFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the id of the thread which originated the log record.static FormatStepthreadNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)Create a format step which emits the name of the thread which originated the log record.static FormatStepthreadNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)Create a format step which emits the name of the thread which originated the log record.
-
-
-
Field Detail
-
THREAD_ID
public static final java.lang.String THREAD_ID
- See Also:
- Constant Field Values
-
DEFAULT_TRUNCATE_BEGINNING
private static final boolean DEFAULT_TRUNCATE_BEGINNING
- See Also:
- Constant Field Values
-
NEW_LINE
private static final java.lang.String NEW_LINE
-
PRECISION_INT_PATTERN
private static final java.util.regex.Pattern PRECISION_INT_PATTERN
-
NULL_FORMATTER
private static final java.util.logging.Formatter NULL_FORMATTER
-
separatorString
private static final java.lang.String separatorString
-
-
Method Detail
-
nullFormatter
public static java.util.logging.Formatter nullFormatter()
Get the null formatter, which outputs nothing.- Returns:
- the null formatter
-
textFormatStep
public static FormatStep textFormatStep(java.lang.String string)
Create a format step which simply emits the given string.- Parameters:
string- the string to emit- Returns:
- a format step
-
applySegments
private static java.lang.String applySegments(int count, java.lang.String subject)Apply up tocounttrailing segments of the given string to the givenbuilder.- Parameters:
count- the maximum number of segments to includesubject- the subject string- Returns:
- the substring
-
applySegments
private static java.lang.String applySegments(java.lang.String precision, java.lang.String subject)Apply up toprecisiontrailing segments of the given string to the givenbuilder. If the precision contains non-integer values- Parameters:
precision- the precision used tosubject- the subject string- Returns:
- the substring
-
loggerNameFormatStep
public static FormatStep loggerNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, java.lang.String precision)
Create a format step which emits the logger name with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneprecision- the argument used for the logger name, may benullor contain dots to format the logger name- Returns:
- the format
-
loggerNameFormatStep
public static FormatStep loggerNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String precision)
Create a format step which emits the logger name with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneprecision- the argument used for the logger name, may benullor contain dots to format the logger name- Returns:
- the format
-
classNameFormatStep
public static FormatStep classNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, java.lang.String precision)
Create a format step which emits the source class name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneprecision- the argument used for the class name, may benullor contain dots to format the class name- Returns:
- the format step
-
classNameFormatStep
public static FormatStep classNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String precision)
Create a format step which emits the source class name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneprecision- the argument used for the class name, may benullor contain dots to format the class name- Returns:
- the format step
-
dateFormatStep
public static FormatStep dateFormatStep(java.util.TimeZone timeZone, java.lang.String formatString, boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the date of the log record with the given justification rules.- Parameters:
timeZone- the time zone to format toformatString- the date format stringleftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
dateFormatStep
public static FormatStep dateFormatStep(java.util.TimeZone timeZone, java.lang.String formatString, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the date of the log record with the given justification rules.- Parameters:
timeZone- the time zone to format toformatString- the date format stringleftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
dateFormatStep
public static FormatStep dateFormatStep(java.lang.String formatString, boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the date of the log record with the given justification rules.- Parameters:
formatString- the date format stringleftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
fileNameFormatStep
public static FormatStep fileNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the source file name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
fileNameFormatStep
public static FormatStep fileNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the source file name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
hostnameFormatStep
public static FormatStep hostnameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, boolean qualified)
Create a format step which emits the hostname.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for nonequalified-trueto use the fully qualified host name,falseto only use the- Returns:
- the format step
-
locationInformationFormatStep
public static FormatStep locationInformationFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the complete source location information with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
locationInformationFormatStep
public static FormatStep locationInformationFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the complete source location information with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
lineNumberFormatStep
public static FormatStep lineNumberFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the source file line number with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
lineNumberFormatStep
public static FormatStep lineNumberFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the source file line number with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
messageFormatStep
public static FormatStep messageFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the formatted log message text with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
messageFormatStep
public static FormatStep messageFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the formatted log message text with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
simpleMessageFormatStep
public static FormatStep simpleMessageFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the formatted log message text (simple version, no exception traces) with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
simpleMessageFormatStep
public static FormatStep simpleMessageFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the formatted log message text (simple version, no exception traces) with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
exceptionFormatStep
public static FormatStep exceptionFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth, boolean extended)
Create a format step which emits the stack trace of an exception with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneextended-trueif the stack trace should attempt to include extended JAR version information- Returns:
- the format step
-
exceptionFormatStep
public static FormatStep exceptionFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, java.lang.String argument, boolean extended)
Create a format step which emits the stack trace of an exception with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for noneextended-trueif the stack trace should attempt to include extended JAR version information- Returns:
- the format step
-
getJarName
static java.lang.String getJarName(java.net.URL resource, java.lang.String classResourceName)
-
resourceKeyFormatStep
public static FormatStep resourceKeyFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the log message resource key (if any) with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
resourceKeyFormatStep
public static FormatStep resourceKeyFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the log message resource key (if any) with the given justification rules.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
methodNameFormatStep
public static FormatStep methodNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the source method name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
methodNameFormatStep
public static FormatStep methodNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the source method name with the given justification rules (NOTE: call stack introspection introduces a significant performance penalty).- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
lineSeparatorFormatStep
public static FormatStep lineSeparatorFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the platform line separator.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
lineSeparatorFormatStep
public static FormatStep lineSeparatorFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the platform line separator.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
levelFormatStep
public static FormatStep levelFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the log level name.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
levelFormatStep
public static FormatStep levelFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the log level name.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
localizedLevelFormatStep
public static FormatStep localizedLevelFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the localized log level name.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
localizedLevelFormatStep
public static FormatStep localizedLevelFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the localized log level name.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
relativeTimeFormatStep
public static FormatStep relativeTimeFormatStep(long baseTime, boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the number of milliseconds since the given base time.- Parameters:
baseTime- the base time as milliseconds as perSystem.currentTimeMillis()leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
relativeTimeFormatStep
public static FormatStep relativeTimeFormatStep(long baseTime, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the number of milliseconds since the given base time.- Parameters:
baseTime- the base time as milliseconds as perSystem.currentTimeMillis()leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
threadFormatStep
public static FormatStep threadFormatStep(java.lang.String argument, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the id ifidis passed as the argument, otherwise the the thread name is used.- Parameters:
argument- the argument which may beidto indicate the thread id ornullto indicate the thread nameleftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
threadIdFormatStep
public static FormatStep threadIdFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the id of the thread which originated the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
threadNameFormatStep
public static FormatStep threadNameFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the name of the thread which originated the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
threadNameFormatStep
public static FormatStep threadNameFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the name of the thread which originated the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
ndcFormatStep
public static FormatStep ndcFormatStep(boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the NDC value of the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
ndcFormatStep
public static FormatStep ndcFormatStep(boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth, int count)
Create a format step which emits the NDC value of the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for nonecount- the limit to the number of segments to format- Returns:
- the format step
-
mdcFormatStep
public static FormatStep mdcFormatStep(java.lang.String key, boolean leftJustify, int minimumWidth, int maximumWidth)
Create a format step which emits the MDC value associated with the given key of the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonemaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
mdcFormatStep
public static FormatStep mdcFormatStep(java.lang.String key, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits the MDC value associated with the given key of the log record.- Parameters:
leftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
-
formatColor
public static FormatStep formatColor(ColorMap colors, java.lang.String color)
-
systemPropertyFormatStep
public static FormatStep systemPropertyFormatStep(java.lang.String argument, boolean leftJustify, int minimumWidth, boolean truncateBeginning, int maximumWidth)
Create a format step which emits a system property value associated with the given key.- Parameters:
argument- the argument that may be a key or key with a default value separated by a colon, cannot benullleftJustify-trueto left justify,falseto right justifyminimumWidth- the minimum field width, or 0 for nonetruncateBeginning-trueto truncate the beginning, otherwisefalseto truncate the endmaximumWidth- the maximum field width (must be greater thanminimumFieldWidth), or 0 for none- Returns:
- the format step
- Throws:
java.lang.IllegalArgumentException- if theargumentisnulljava.lang.SecurityException- if a security manager exists and itscheckPropertyAccessmethod doesn't allow access to the specified system property
-
parsePatternSegments
static java.util.Map<java.lang.Integer,Formatters.Segment> parsePatternSegments(java.lang.String pattern)
-
parseCategorySegments
static java.util.Deque<java.lang.String> parseCategorySegments(java.lang.String category)
-
findHostname
private static java.lang.String findHostname(java.util.Properties props, java.util.Map<java.lang.String,java.lang.String> env, boolean qualified)
-
findQualifiedHostname
private static java.lang.String findQualifiedHostname(java.util.Properties props, java.util.Map<java.lang.String,java.lang.String> env)
-
-