By default each CompactFormatter is initialized using the following LogManager configuration properties where <formatter-name> refers to the fully qualified class name or the fully qualified derived class name of the formatter. If properties are not defined, or contain invalid values, then the specified default values are used.
| Modifier and Type | Class and Description |
|---|---|
| private class | CompactFormatter.Alternate
Used to format two arguments as fixed length message. |
| Modifier and Type | Field and Description |
|---|---|
| private final String | fmt
Holds the java.util.Formatter pattern. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Throwable | |
| private boolean | Returns: true if this frame should be ignored.the stack trace element. s)Determines if a stack frame should be ignored as the cause of an error. |
| private String | Returns: a String that best describes the call site.the fill stack to examine. trace)Finds and formats the first stack frame of interest. |
| public String | Returns: the formatted record.the log record to format. record)Implements abstract java. |
| public String | Returns: the formatted back trace.the log record to format. record)Formats the back trace for the given log record. |
| public String | Returns: empty string if nothing was thrown or formatted string.the record. record)Formats the thrown property of a LogRecord as an error message. |
| public String | Returns: the formatted logger name.the record. record)Formats the level property of the given log record. |
| public String | Returns: the formatted logger name.the record. record)Formats the logger name property of the given log record. |
| public String | Returns: the formatted message string.the log record. record)Overrides java. |
| public String | Returns: the empty string if null was given or the formatted message string from the throwable which may be null.the throwable to format or null. t)Formats the message from the thrown property of the log record. |
| public String | Returns: the formatted source of the log record.the record. record)Formats the source from the given log record. |
| private String | Returns: the formatted stack trace element.the stack trace element to format. s)Formats a stack trace element into a simple call site. |
| public Number | Returns: the formatted thread id as a number.the record. record)Formats the thread id property of the given log record. |
| public String | Returns: empty string if nothing was thrown or formatted string.the record. record)Formats the thrown property of a LogRecord. |
| private Comparable | Returns: a zoned date time or a legacy date object.the current log record. record)Gets the zoned date time from the given log record. |
| protected boolean | Returns: true if this frame should be ignored.the stack trace element. s)Determines if a stack frame should be ignored as the cause of an error. |
| private String | Returns: the java.util.Formatter format string.the class name prefix. p)Creates the format pattern for this formatter. |
| private static boolean | Returns: true if null or spaces.the string or null. s)Determines is the given string is null or spaces. |
| private boolean | Returns: true if the line number is unknown.the stack trace element. s)Determines if a stack trace element represents a reflection frame. |
| private boolean | Returns: true if this frame should be ignored.the stack trace element. s)Determines if a stack frame is for a static utility class. |
| private boolean | Returns: true if synthetic.the stack trace element. s)Determines if a stack trace element is for a synthetic method. |
| private boolean | Returns: true if the line number is unknown.the stack trace element. s)Determines if a stack trace element has an unknown line number or a native line number. |
| private static Class | Returns: an array of classes never null.Used to load declared classes encase class loader doesn't allow loading during JVM termination. |
| private static String | Returns: the modified message string.the message. msg, Throwable the throwable cause chain to search or null. t)Searches the given message for all instances fully qualified class name with simple class name based off of the types contained in the given parameter array. |
| private static String | Returns: the modified message string.the message or null. msg, Object[] the parameter array or null. p)Searches the given message for all instances fully qualified class name with simple class name based off of the types contained in the given parameter array. |
| private static String | Returns: the simple class name or null.the class object. k)Gets the simple class name from the given class. |
| private static String | Returns: the simple class name or given input.the fully qualified class name prefix or null. name)Converts a fully qualified class name to a simple class name. |
| private static String | Returns: the simple file name or null.the full file name or null. name)Converts a file name with an extension to a file name without an extension. |
| protected String | Returns: null if the argument was null otherwise, an alternate string.any string or null. s)Defines the alternate format. |
| fmt | back to summary |
|---|---|
| private final String fmt Holds the java.util.Formatter pattern. | |
| CompactFormatter | back to summary |
|---|---|
| public CompactFormatter() Creates an instance with a default format pattern. | |
| CompactFormatter | back to summary |
|---|---|
| public CompactFormatter(final String format) Creates an instance with the given format pattern. | |
| apply | back to summary |
|---|---|
| protected Throwable apply(final Throwable t) Chooses a single throwable from the cause chain that will be formatted. This implementation chooses the throwable that best describes the chain. Subclasses can override this method to choose an alternate throwable for formatting.
| |
| defaultIgnore | back to summary |
|---|---|
| private boolean defaultIgnore(final StackTraceElement s) Determines if a stack frame should be ignored as the cause of an error. This does not check for unknown line numbers because code can be compiled without debugging info.
| |
| findAndFormat | back to summary |
|---|---|
| private String findAndFormat(final StackTraceElement[] trace) Finds and formats the first stack frame of interest.
| |
| format | back to summary |
|---|---|
| public String format(final LogRecord record) Implements abstract java. Format the given log record and returns the formatted string. The java.util argument indexes are assigned to the following properties:
Some example formats:
| |
| formatBackTrace | back to summary |
|---|---|
| public String formatBackTrace(final LogRecord record) Formats the back trace for the given log record.
| |
| formatError | back to summary |
|---|---|
| public String formatError(final LogRecord record) Formats the thrown property of a LogRecord as an error message. The returned string will not contain a back trace.
| |
| formatLevel | back to summary |
|---|---|
| public String formatLevel(final LogRecord record) Formats the level property of the given log record.
| |
| formatLoggerName | back to summary |
|---|---|
| public String formatLoggerName(final LogRecord record) Formats the logger name property of the given log record.
| |
| formatMessage | back to summary |
|---|---|
| public String formatMessage(final LogRecord record) Overrides java. Formats message for the log record. This method removes any fully qualified throwable class names from the message. | |
| formatMessage | back to summary |
|---|---|
| public String formatMessage(final Throwable t) Formats the message from the thrown property of the log record. This method replaces fully qualified throwable class names from the message cause chain with simple class names. | |
| formatSource | back to summary |
|---|---|
| public String formatSource(final LogRecord record) Formats the source from the given log record.
| |
| formatStackTraceElement | back to summary |
|---|---|
| private String formatStackTraceElement(final StackTraceElement s) Formats a stack trace element into a simple call site.
| |
| formatThreadID | back to summary |
|---|---|
| public Number formatThreadID(final LogRecord record) Formats the thread id property of the given log record. By default this
is formatted as a
| |
| formatThrown | back to summary |
|---|---|
| public String formatThrown(final LogRecord record) Formats the thrown property of a LogRecord. The returned string will contain a throwable message with a back trace.
| |
| formatZonedDateTime | back to summary |
|---|---|
| private Comparable Gets the zoned date time from the given log record.
| |
| ignore | back to summary |
|---|---|
| protected boolean ignore(final StackTraceElement s) Determines if a stack frame should be ignored as the cause of an error.
| |
| initFormat | back to summary |
|---|---|
| private String initFormat(final String p) Creates the format pattern for this formatter.
| |
| isNullOrSpaces | back to summary |
|---|---|
| private static boolean isNullOrSpaces(final String s) Determines is the given string is null or spaces.
| |
| isReflection | back to summary |
|---|---|
| private boolean isReflection(final StackTraceElement s) Determines if a stack trace element represents a reflection frame.
| |
| isStaticUtility | back to summary |
|---|---|
| private boolean isStaticUtility(final StackTraceElement s) Determines if a stack frame is for a static utility class.
| |
| isSynthetic | back to summary |
|---|---|
| private boolean isSynthetic(final StackTraceElement s) Determines if a stack trace element is for a synthetic method.
| |
| isUnknown | back to summary |
|---|---|
| private boolean isUnknown(final StackTraceElement s) Determines if a stack trace element has an unknown line number or a native line number.
| |
| loadDeclaredClasses | back to summary |
|---|---|
| private static Class Used to load declared classes encase class loader doesn't allow loading during JVM termination. This method is used with unit testing.
| |
| replaceClassName | back to summary |
|---|---|
| private static String replaceClassName(String msg, Throwable t) Searches the given message for all instances fully qualified class name with simple class name based off of the types contained in the given parameter array. | |
| replaceClassName | back to summary |
|---|---|
| private static String replaceClassName(String msg, Object[] p) Searches the given message for all instances fully qualified class name with simple class name based off of the types contained in the given parameter array. | |
| simpleClassName | back to summary |
|---|---|
| private static String simpleClassName(final Class<?> k) Gets the simple class name from the given class. This is a workaround for BUG ID JDK-8057919. | |
| simpleClassName | back to summary |
|---|---|
| private static String simpleClassName(String name) Converts a fully qualified class name to a simple class name. If the leading part of the given string is not a legal class name then the given string is returned. | |
| simpleFileName | back to summary |
|---|---|
| private static String simpleFileName(String name) Converts a file name with an extension to a file name without an extension. | |
| toAlternate | back to summary |
|---|---|
| protected String toAlternate(final String s) Defines the alternate format. This implementation removes all control characters from the given string. | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | left
The left side of the output. |
| private final String | right
The right side of the output. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | formatTo(Formatter
The formatter, int formatter. Implementing classes may call
formatter.out() or formatter.locale() to obtain the Appendable or Locale used by this
formatter respectively.The flags modify the output format. The value is interpreted as
a bitmask. Any combination of the following flags may be set:
flags, int FormattableFlags#LEFT_JUSTIFY, FormattableFlags#UPPERCASE, and FormattableFlags#ALTERNATE. If no flags are set, the default
formatting of the implementing class will apply.The minimum number of characters to be written to the output.
If the length of the converted value is less than the
width, int width then the output will be padded by
' ' until the total number of characters
equals width. The padding is at the beginning by default. If
the FormattableFlags#LEFT_JUSTIFY flag is set then the
padding will be at the end. If width is -1
then there is no minimum.The maximum number of characters to be written to the output.
The precision is applied before the width, thus the output will
be truncated to precision)precision characters even if the
width is greater than the precision. If
precision is -1 then there is no explicit
limit on the number of characters.Implements java. formatter.
|
| private String |
| left | back to summary |
|---|---|
| private final String left The left side of the output. | |
| right | back to summary |
|---|---|
| private final String right The right side of the output. | |
| Alternate | back to summary |
|---|---|
| pack-priv Alternate(final String left, final String right) Creates an alternate output. | |
| formatTo | back to summary |
|---|---|
| public void formatTo(Formatter formatter, int flags, int width, int precision) Implements java. Doc from java. Formats the object using the provided
| |
| pad | back to summary |
|---|---|
| private String pad(int flags, String s, int length) Pad the given input string. | |