public class MessageUtils
extends java.lang.Object
Internally, Jansi is used to render ANSI colors on any platform.
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
JANSI |
private static java.lang.Thread |
shutdownHook
Reference to the JVM shutdown hook, if registered
|
private static java.lang.Object |
STARTUP_SHUTDOWN_MONITOR
Synchronization monitor for the "uninstall"
|
| Constructor and Description |
|---|
MessageUtils() |
| Modifier and Type | Method and Description |
|---|---|
static MessageBuilder |
buffer()
Create a default message buffer.
|
static MessageBuilder |
buffer(int size)
Create a message buffer with an internal buffer of defined size.
|
static MessageBuilder |
buffer(java.lang.StringBuilder builder)
Create a message buffer with defined String builder.
|
private static void |
doSystemUninstall() |
static boolean |
isColorEnabled()
Is message color enabled: requires JAnsi available (through Maven) and the color has not been disabled.
|
static LoggerLevelRenderer |
level()
Create a logger level renderer.
|
static void |
registerShutdownHook()
Register a shutdown hook with the JVM runtime, uninstalling Ansi support on
JVM shutdown unless is has already been uninstalled at that time.
|
static void |
setColorEnabled(boolean flag)
Enables message color (if JAnsi is available).
|
static java.lang.String |
stripAnsiCodes(java.lang.String msg)
Remove any ANSI code from a message (colors or other escape sequences).
|
static void |
systemInstall()
Install color support.
|
static void |
systemUninstall()
Undo a previous
systemInstall(). |
private static final boolean JANSI
private static java.lang.Thread shutdownHook
private static final java.lang.Object STARTUP_SHUTDOWN_MONITOR
public static void systemInstall()
public static void systemUninstall()
systemInstall(). If systemInstall() was called
multiple times, systemUninstall() must be called call the same number of times before
it is actually uninstalled.private static void doSystemUninstall()
public static void setColorEnabled(boolean flag)
flag - public static boolean isColorEnabled()
public static MessageBuilder buffer()
public static MessageBuilder buffer(java.lang.StringBuilder builder)
public static MessageBuilder buffer(int size)
public static LoggerLevelRenderer level()
public static java.lang.String stripAnsiCodes(java.lang.String msg)
msg - message eventually containing ANSI codespublic static void registerShutdownHook()
Delegates to doSystemUninstall() for the actual uninstall procedure
Runtime.addShutdownHook(Thread),
systemUninstall(),
doSystemUninstall()