public class MinecraftFormattingConverter
extends LogEventPatternConverter
The MinecraftFormattingConverter
can be only used together with
TerminalConsoleAppender
to detect if the current console supports
color output. When running in an unsupported environment, it will
automatically strip all formatting codes instead.
TerminalConsoleAppender.ANSI_OVERRIDE_PROPERTY
may be used
to force the use of ANSI colors even in unsupported environments. As an
alternative, KEEP_FORMATTING_PROPERTY
may be used to keep the
raw Minecraft formatting codes.
Example usage: %minecraftFormatting{%message}
It can be configured to always strip formatting codes from the message:
%minecraftFormatting{%message}{strip}
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEEP_FORMATTING_PROPERTY
System property that allows disabling the replacement of Minecraft
formatting codes entirely, keeping them in the console output.
|
Modifier | Constructor and Description |
---|---|
protected |
MinecraftFormattingConverter(java.util.List<PatternFormatter> formatters,
boolean strip)
Construct the converter.
|
Modifier and Type | Method and Description |
---|---|
void |
format(LogEvent event,
java.lang.StringBuilder toAppendTo) |
static MinecraftFormattingConverter |
newInstance(Configuration config,
java.lang.String[] options)
Gets a new instance of the
MinecraftFormattingConverter with the
specified options. |
public static final java.lang.String KEEP_FORMATTING_PROPERTY
If this system property is not set, or set to any value except
true
, all Minecraft formatting codes will be replaced
or stripped from the console output.
protected MinecraftFormattingConverter(java.util.List<PatternFormatter> formatters, boolean strip)
formatters
- The pattern formatters to generate the text to manipulatestrip
- If true, the converter will strip all formatting codespublic void format(LogEvent event, java.lang.StringBuilder toAppendTo)
public static MinecraftFormattingConverter newInstance(Configuration config, java.lang.String[] options)
MinecraftFormattingConverter
with the
specified options.config
- The current configurationoptions
- The pattern optionsMinecraftFormattingConverter