@Plugin(name="minecraftFormatting",
category="Converter")
public class MinecraftFormattingConverter
extends org.apache.logging.log4j.core.pattern.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 |
---|---|
private boolean |
ansi |
private static java.lang.String |
ANSI_RESET |
private static java.lang.String[] |
ansiCodes |
private static char |
COLOR_CHAR |
private java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> |
formatters |
private static boolean |
KEEP_FORMATTING |
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.
|
private static java.lang.String |
LOOKUP |
Modifier | Constructor and Description |
---|---|
protected |
MinecraftFormattingConverter(java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> formatters,
boolean strip)
Construct the converter.
|
Modifier and Type | Method and Description |
---|---|
void |
format(org.apache.logging.log4j.core.LogEvent event,
java.lang.StringBuilder toAppendTo) |
private static void |
format(java.lang.String s,
java.lang.StringBuilder result,
int start,
boolean ansi) |
static MinecraftFormattingConverter |
newInstance(org.apache.logging.log4j.core.config.Configuration config,
java.lang.String[] options)
Gets a new instance of the
MinecraftFormattingConverter with the
specified options. |
format, handlesThrowable, isVariable
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.
private static final boolean KEEP_FORMATTING
private static final java.lang.String ANSI_RESET
private static final char COLOR_CHAR
private static final java.lang.String LOOKUP
private static final java.lang.String[] ansiCodes
private final boolean ansi
private final java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> formatters
protected MinecraftFormattingConverter(java.util.List<org.apache.logging.log4j.core.pattern.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(org.apache.logging.log4j.core.LogEvent event, java.lang.StringBuilder toAppendTo)
format
in class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
private static void format(java.lang.String s, java.lang.StringBuilder result, int start, boolean ansi)
@Nullable public static MinecraftFormattingConverter newInstance(org.apache.logging.log4j.core.config.Configuration config, java.lang.String[] options)
MinecraftFormattingConverter
with the
specified options.config
- The current configurationoptions
- The pattern optionsMinecraftFormattingConverter