Top Description Inners Fields Constructors Methods
org.jboss.logmanager.formatters

public abstract Class StructuredFormatter

extends ExtFormatter
Class Inheritance
Known Direct Subclasses
org.jboss.logmanager.formatters.XmlFormatter, org.jboss.logmanager.formatters.JsonFormatter
Annotations
@SuppressWarnings:unused, WeakerAccess
Imports
java.io.Writer, java.time.ZoneId, java.time.format.DateTimeFormatter, java.util.Collections, .EnumMap, .IdentityHashMap, .Map, org.jboss.logmanager.ExtFormatter, .ExtLogRecord, .PropertyValues

An abstract class that uses a generator to help generate structured data from a record.

Note that including details can be expensive in terms of calculating the caller.

By default the record delimiter is set to \n.

Author
James R. Perkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
StructuredFormatter.ExceptionOutputType

Defines the way a cause will be formatted.

protected static interface
StructuredFormatter.Generator

A generator used to create the structured output.

public static enum
StructuredFormatter.Key

The key used for the structured log record data.

Field Summary

Modifier and TypeField and Description
private DateTimeFormatter
private volatile String
private volatile StructuredFormatter.ExceptionOutputType
private final Map<StructuredFormatter.Key, String>
private final String
private String
private Map<String, String>
private volatile boolean
private int
private final StringBuilderWriter
private ZoneId

Constructor Summary

AccessConstructor and Description
protected
protected
protected
StructuredFormatter(final String keyOverrides)

private
StructuredFormatter(final Map<StructuredFormatter.Key, String> keyOverrides, final String keyOverridesValue)

Method Summary

Modifier and TypeMethod and Description
private void
addException(final StructuredFormatter.Generator generator, final Throwable throwable, final Map<Throwable, Integer> seen)

private void
protected void
after(final StructuredFormatter.Generator
the generator to use
generator
,
final ExtLogRecord
the log record
record
)

Invoked after the structured data has been added to the generator.

protected void
before(final StructuredFormatter.Generator
the generator to use
generator
,
final ExtLogRecord
the log record
record
)

Invoked before the structured data is added to the generator.

protected abstract StructuredFormatter.Generator

Returns:

the generator to use
createGenerator
(Writer writer)

Creates the generator used to create the structured data.

public final synchronized String
format(final ExtLogRecord
the log record
record
)

Implements abstract org.jboss.logmanager.ExtFormatter.format.

Format a message using an extended log record.

public synchronized DateTimeFormatter

Returns:

the current formatter
getDateTimeFormatter
()

Returns the current formatter used to format a records date and time.

public StructuredFormatter.ExceptionOutputType

Returns:

the output type for exceptions
getExceptionOutputType
()

Get the current output type for exceptions.

protected final String

Returns:

the overridden key or the default key if no override exists
getKey
(final StructuredFormatter.Key
the default key
defaultKey
)

Checks to see if the key should be overridden.

public String

Returns:

a string representation of the key overrides or null if no overrides were configured
getKeyOverrides
()

A string representation of the key overrides.

public String

Returns:

the meta data string or null if one was not set
getMetaData
()

Returns the value set for meta data.

public String

Returns:

the end of record delimiter or null if no delimiter is desired
getRecordDelimiter
()

Returns the character used to indicate the record has is complete.

public synchronized ZoneId

Returns:

the current zone id
getZoneId
()

Returns the current zone id used for the date and time formatter.

public boolean
isCallerCalculationRequired()

Overrides org.jboss.logmanager.ExtFormatter.isCallerCalculationRequired.

Determines whether or not this formatter will require caller, source level, information when a log record is formatted.

protected boolean

Returns:

true if detailed output should be written, otherwise false
isDetailedExceptionOutputType
()

Checks the exception output type and determines if detailed output should be written.

protected boolean

Returns:

true if formatted exception output should be written, otherwise false
isFormattedExceptionOutputType
()

Checks the exception output type and determines if formatted output should be written.

private static boolean
isNotNullOrEmpty(final String value)

public boolean

Returns:

true if details should be printed, otherwise false
isPrintDetails
()

Indicates whether or not details should be printed.

public synchronized void
setDateFormat(final String
the pattern to use or null to use a default pattern
pattern
)

Sets the pattern to use when formatting the date.

public void
setExceptionOutputType(final StructuredFormatter.ExceptionOutputType
the desired output type, if null ExceptionOutputType#DETAILED is used
exceptionOutputType
)

Set the output type for exceptions.

public synchronized void
setMetaData(final String
the meta data to set or null to not format any meta data
metaData
)

Sets the meta data to use in the structured format.

public void
setPrintDetails(final boolean
true if details should be printed
printDetails
)

Sets whether or not details should be printed.

public void
setRecordDelimiter(final String
the delimiter to be used or null to not use a delimiter
eorDelimiter
)

Sets the value to be used to indicate the end of a record.

public void
setZoneId(final String
the zone id or null to use the system default
zoneId
)

Sets the ZoneId to use when formatting the date and time from the java.util.logging.LogRecord.

Inherited from org.jboss.logmanager.ExtFormatter:
formatformatMessageformatMessageLegacyformatMessageNoneformatMessagePrintfwrap