TextRendererpublic 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)*)*}%n
For example:
%message{ansi}{WarningStyle=red,bold KeyStyle=white ValueStyle=blue}%n
The 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 | Description |
|---|---|---|
static Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> |
DefaultExceptionStyleMap |
| Constructor | Description |
|---|---|
JAnsiTextRenderer(String[] formats,
Map<String,org.fusesource.jansi.AnsiRenderer.Code[]> defaultStyleMap) |
| Modifier and Type | Method | 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 void render(String input, StringBuilder output, String styleName) throws IllegalArgumentException
TextRendererrender in interface TextRendererinput - The inputoutput - The outputstyleName - The style name to use to render the input on the output.IllegalArgumentExceptionpublic void render(StringBuilder input, StringBuilder output) throws IllegalArgumentException
TextRendererrender in interface TextRendererinput - The inputoutput - The outputIllegalArgumentExceptionCopyright © 1999-2018. 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.