ALox
V. 2402 R. 0
A logger that logs all messages to the PrintStream instance provided in the constructor. The name of the Logger defaults to "ANSI_LOGGER".
ALox text logger escape sequences (see class ESC ) are translated to ANSI escape sequences. Support for ANSI escape sequences (also referred to as VT100 terminal emulation ) is available on most unix terminal windows. Besides text colors, bold and italics font style can be set. ANSI escape sequences are also available in various IDE output windows.
Foreground and background colors can be set to be either light/dark or dark/light. This improves the readability of log output a lot and even allows to read if foreground and background colors are the same (they then still differ). However, the right setting for this is dependent on the color scheme of the final output device (window). To manipulate the right setting, see field useLightColors and also configuration variable ALOX_CONSOLE_LIGHT_COLORS .
In the constructor, a default format string and some other definitions in member metaInfo get set to include color settings. Of-course, these publicly accessible format attributes can be customized after creation.
There is not 100% match between the ANSI sequences and the definitions in ESC . For example ESC does not provide all ANSI colors and no blinking. On the other hand, ANSI does not allow to reset the style without resetting the colors. Of-course, it is no problem to log other ANSI codes directly into an AnsiLogger . In this case, other Loggers that might be attached to the same Lox and that do not support ANSI must be equipped with corresponding replacement information. In other words: To support the same log output into different loggers, it is recommended to use ESC sequences instead of directly using ANSI codes.
The ANSI codes used by this class are exposed through a list of fields. They might be useful for manipulating the attributes of the metaInfo member, which of-course might contain native ANSI sequences. (In contrast to the log messages themselves, this meta information is specific to a logger instance and this way it does not need to be replaced in other loggers).
static final String ANSI_BG_BLACK ="\033[40m"
Select black as background color.
static final String ANSI_BG_BLUE ="\033[44m"
Select blue as background color.
static final String ANSI_BG_CYAN ="\033[46m"
Select cyan as background color.
static final String ANSI_BG_GRAY ="\033[48;5;240m"
Select gray as background color.
static final String ANSI_BG_GREEN ="\033[42m"
Select green as background color.
static final String ANSI_BG_LIGHT_BLUE ="\033[48;5;12m"
Select light blue as background color.
static final String ANSI_BG_LIGHT_CYAN ="\033[48;5;14m"
Select light cyan as background color.
static final String ANSI_BG_LIGHT_GRAY ="\033[48;5;250m"
Select light gray as background color.
static final String ANSI_BG_LIGHT_GREEN ="\033[48;5;10m"
Select light green as background color.
static final String ANSI_BG_LIGHT_MAGENTA ="\033[48;5;13m"
Select light magenta as background color.
static final String ANSI_BG_LIGHT_RED ="\033[48;5;09m"
Select light red as background color.
static final String ANSI_BG_LIGHT_YELLOW ="\033[48;5;11m"
Select light yellow as background color.
static final String ANSI_BG_MAGENTA ="\033[45m"
Select magenta as background color.
static final String ANSI_BG_RED ="\033[41m"
Select red as background color.
static final String ANSI_BG_STD_COL ="\033[49m"
Select standard background color.
static final String ANSI_BG_WHITE ="\033[48;5;15m"
Select white as background color.
static final String ANSI_BG_YELLOW ="\033[43m"
Select yellow as background color.
static final String ANSI_BLACK ="\033[30m"
Select black as foreground color.
static final String ANSI_BLUE ="\033[34m"
Select blue as foreground color.
static final String ANSI_BOLD ="\033[1m"
Select bold font style.
static final String ANSI_CYAN ="\033[36m"
Select cyan as foreground color.
static final String ANSI_GRAY ="\033[38;5;240m"
Select gray as foreground color.
static final String ANSI_GREEN ="\033[32m"
Select green as foreground color.
static final String ANSI_ITALICS ="\033[3m"
Select italics font style.
static final String ANSI_LIGHT_BLUE ="\033[38;5;12m"
Select light blue as foreground color.
static final String ANSI_LIGHT_CYAN ="\033[38;5;14m"
Select light cyan as foreground color.
static final String ANSI_LIGHT_GRAY ="\033[38;5;250m"
Select light gray as foreground color.
static final String ANSI_LIGHT_GREEN ="\033[38;5;10m"
Select light green as foreground color.
static final String ANSI_LIGHT_MAGENTA ="\033[38;5;13m"
Select light magenta as foreground color.
static final String ANSI_LIGHT_RED ="\033[38;5;09m"
Select light red as foreground color.
static final String ANSI_LIGHT_YELLOW ="\033[38;5;11m"
Select light yellow as foreground color.
static final String ANSI_MAGENTA ="\033[35m"
Select magenta as foreground color.
static final String ANSI_RED ="\033[31m"
Select red as foreground color.
static final String ANSI_RESET ="\033[0m"
Reset colors and font style.
static final String ANSI_STD_COL ="\033[39m"
Select standard foreground color.
static final String ANSI_STD_STYLE ="\033[0m"
Select standard font style.
static final String ANSI_WHITE ="\033[38;5;15m"
Select white as foreground color.
static final String ANSI_YELLOW ="\033[33m"
Select yellow as foreground color.
AnsiLogger (PrintStream out , boolean usesStdStreams )
AnsiLogger (PrintStream out , boolean usesStdStreams , String name )
AnsiLogger (PrintStream out , boolean usesStdStreams , String name , String typeName )
int addAcquirer (ThreadLock newAcquirer)
void clearReplacements ()
void log (Domain domain, Verbosity verbosity, ArrayList< Object > logables, ScopeInfo scope)
int removeAcquirer (ThreadLock acquirer)
void resetAutoSizes ()
void setReplacement (String searched, String replacement)
String getName ()
String getTypeName ()
String toString ()
SmartLock ()
int cntAcquirers ()
ThreadLock ()
ThreadLock (LockMode lockMode )
ThreadLock (LockMode lockMode , Safeness safeness)
void acquire ()
int dbgCountAcquirements (Thread thread)
LockMode getMode ()
Safeness getSafeness ()
void release ()
void setSafeness (Safeness safeness)
boolean willRelease ()
◆ AnsiLogger() [1/3]
AnsiLogger
(
PrintStream
out ,
boolean
usesStdStreams ,
String
name ,
String
typeName
)
Creates an AnsiLogger with the given PrintStream and name.
Parameters
out A java.io.PrintStream to write the log data to.
usesStdStreams Denotes whether this logger writes to the standard output streams .
name The name of the Logger , defaults to what is provided with parameter typeName .
typeName The type of the Logger , defaults to "ANSI".
◆ AnsiLogger() [2/3]
AnsiLogger
(
PrintStream
out ,
boolean
usesStdStreams ,
String
name
)
Creates an AnsiLogger with the given PrintStream and name.
Parameters
out A java.io.PrintStream to write the log data to.
usesStdStreams Denotes whether this logger writes to the standard output streams .
name The name of the Logger . Defaults to "ANSI".
◆ AnsiLogger() [3/3]
AnsiLogger
(
PrintStream
out ,
boolean
usesStdStreams
)
Overwritten constructor providing default parameters.
Parameters
out A java.io.PrintStream to write the log data to.
usesStdStreams Denotes whether this logger writes to the standard output streams .
◆ construct()
void construct
(
PrintStream
ps )
protected
Helper method used by the constructors.
Parameters
ps A java.io.PrintStream to write the log data to.
◆ logText()
Implementation of the abstract method of parent class TextLogger. Logs messages to the application console.
Parameters
domain The Log Domain .
verbosity The verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only.
msg The log message.
scope Information about the scope of the Log Statement ..
lineNumber The line number of a multi-line message, starting with 0. For single line messages this is -1.
Reimplemented from TextLogger .
◆ notifyMultiLineOp()
void notifyMultiLineOp
(
Phase
phase )
protected
Empty implementation.
Parameters
phase The phase of the multi-line operation (ignored).
Reimplemented from TextLogger .
◆ ansiCols
Initial value: =
{
ANSI_RED ,
ANSI_GREEN ,
ANSI_YELLOW ,
ANSI_BLUE ,
ANSI_MAGENTA ,
ANSI_CYAN ,
ANSI_BLACK ,
ANSI_WHITE ,
ANSI_GRAY ,
ANSI_STD_COL ,
ANSI_BG_RED ,
ANSI_BG_GREEN ,
ANSI_BG_YELLOW ,
ANSI_BG_BLUE ,
ANSI_BG_MAGENTA ,
ANSI_BG_CYAN ,
ANSI_BG_BLACK ,
ANSI_BG_WHITE ,
ANSI_BG_GRAY ,
ANSI_BG_STD_COL ,
ANSI_LIGHT_RED ,
ANSI_LIGHT_GREEN ,
ANSI_LIGHT_YELLOW ,
ANSI_LIGHT_BLUE ,
ANSI_LIGHT_MAGENTA ,
ANSI_LIGHT_CYAN ,
ANSI_BG_BLACK ,
ANSI_BG_WHITE ,
ANSI_LIGHT_GRAY ,
ANSI_STD_COL ,
}
Internal table used to convert ESC colors to ANSI colors
◆ out
The PrintStream provided in the constructor.
◆ useLightColors
Foreground and background colors chosen by this class might differ in their intensity. This increases the overall readability by increasing the contrast. If the background color of a console window is dark, then the background colors of colored log output should be darker colors than the foreground colors - and vice versa.
Depending on the setting of this field, ALox escape codes for colors are translated to normal ANSI colors or lighter ones:
The configuration variable ALOX_CONSOLE_LIGHT_COLORS allows to externally modify this flag. It is read once within the constructor .
The documentation for this class was generated from the following file:
static final String ANSI_WHITE
Select white as foreground color.
Definition: AnsiLogger.java:80
static final String ANSI_LIGHT_GRAY
Select light gray as foreground color.
Definition: AnsiLogger.java:101
static final String ANSI_BG_BLACK
Select black as background color.
Definition: AnsiLogger.java:90
static final String ANSI_LIGHT_YELLOW
Select light yellow as foreground color.
Definition: AnsiLogger.java:97
static final String ANSI_BG_YELLOW
Select yellow as background color.
Definition: AnsiLogger.java:86
static final String ANSI_YELLOW
Select yellow as foreground color.
Definition: AnsiLogger.java:75
static final String ANSI_LIGHT_BLUE
Select light blue as foreground color.
Definition: AnsiLogger.java:98
static final String ANSI_GRAY
Select gray as foreground color.
Definition: AnsiLogger.java:81
static final String ANSI_LIGHT_CYAN
Select light cyan as foreground color.
Definition: AnsiLogger.java:100
static final String ANSI_MAGENTA
Select magenta as foreground color.
Definition: AnsiLogger.java:77
static final String ANSI_BG_RED
Select red as background color.
Definition: AnsiLogger.java:84
static final String ANSI_BG_WHITE
Select white as background color.
Definition: AnsiLogger.java:91
static final String ANSI_BG_GRAY
Select gray as background color.
Definition: AnsiLogger.java:92
static final String ANSI_RED
Select red as foreground color.
Definition: AnsiLogger.java:73
static final String ANSI_BG_BLUE
Select blue as background color.
Definition: AnsiLogger.java:87
static final String ANSI_BG_CYAN
Select cyan as background color.
Definition: AnsiLogger.java:89
static final String ANSI_BG_LIGHT_RED
Select light red as background color.
Definition: AnsiLogger.java:103
static final String ANSI_BG_GREEN
Select green as background color.
Definition: AnsiLogger.java:85
static final String ANSI_BG_LIGHT_GRAY
Select light gray as background color.
Definition: AnsiLogger.java:109
static final String ANSI_BG_LIGHT_CYAN
Select light cyan as background color.
Definition: AnsiLogger.java:108
static final String ANSI_BG_LIGHT_MAGENTA
Select light magenta as background color.
Definition: AnsiLogger.java:107
static final String ANSI_CYAN
Select cyan as foreground color.
Definition: AnsiLogger.java:78
static final String ANSI_LIGHT_GREEN
Select light green as foreground color.
Definition: AnsiLogger.java:96
static final String ANSI_STD_COL
Select standard foreground color.
Definition: AnsiLogger.java:82
static final String ANSI_BLUE
Select blue as foreground color.
Definition: AnsiLogger.java:76
static final String ANSI_BLACK
Select black as foreground color.
Definition: AnsiLogger.java:79
static final String ANSI_BG_MAGENTA
Select magenta as background color.
Definition: AnsiLogger.java:88
static final String ANSI_BG_STD_COL
Select standard background color.
Definition: AnsiLogger.java:93
static final String ANSI_BG_LIGHT_GREEN
Select light green as background color.
Definition: AnsiLogger.java:104
static final String ANSI_LIGHT_MAGENTA
Select light magenta as foreground color.
Definition: AnsiLogger.java:99
static final String ANSI_BG_LIGHT_YELLOW
Select light yellow as background color.
Definition: AnsiLogger.java:105
static final String ANSI_GREEN
Select green as foreground color.
Definition: AnsiLogger.java:74
static final String ANSI_LIGHT_RED
Select light red as foreground color.
Definition: AnsiLogger.java:95
static final String ANSI_BG_LIGHT_BLUE
Select light blue as background color.
Definition: AnsiLogger.java:106