public final class JAnsiTextRenderer extends Object implements TextRenderer
@|code(,code)* text|@For example, to render the message
"Hello"
in green, use:
@|green Hello|@To render the message
"Hello"
in bold and red, use:
@|bold,red Warning!|@You can also define custom style names in the configuration with the syntax:
%message{ansi}{StyleName=value(,value)*( StyleName=value(,value)*)*}%nFor example:
%message{ansi}{WarningStyle=red,bold KeyStyle=white ValueStyle=blue}%nThe call site can look like this:
logger.info("@|KeyStyle {}|@ = @|ValueStyle {}|@", entry.getKey(), entry.getValue());Note: This class originally copied and then heavily modified code from JAnsi's AnsiRenderer (which is licensed as Apache 2.0.)
AnsiRenderer
Modifier and Type | Field and Description |
---|---|
static Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> |
DefaultExceptionStyleMap |
Constructor and Description |
---|
JAnsiTextRenderer(String[] formats,
Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> defaultStyleMap) |
Modifier and Type | Method and Description |
---|---|
Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> |
getStyleMap() |
void |
render(StringBuilder input,
StringBuilder output)
Renders input text to an output.
|
void |
render(String input,
StringBuilder output,
String styleName)
Renders input text to an output.
|
String |
toString() |
public static final Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> DefaultExceptionStyleMap
public JAnsiTextRenderer(String[] formats, Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> defaultStyleMap)
public Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> getStyleMap()
public void render(String input, StringBuilder output, String styleName) throws IllegalArgumentException
TextRenderer
render
in interface TextRenderer
input
- The inputoutput
- The outputstyleName
- The style name to use to render the input on the output.IllegalArgumentException
public void render(StringBuilder input, StringBuilder output) throws IllegalArgumentException
TextRenderer
render
in interface TextRenderer
input
- The inputoutput
- The outputIllegalArgumentException
Copyright © 1999-2020 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.