Class AnsiColorLogger
- All Implemented Interfaces:
EventListener
,BuildListener
,BuildLogger
If used with the -logfile option, the output file will contain all the necessary escape codes to display the text in colorized mode when displayed in the console using applications like cat, more, etc.
This is designed to work on terminals that support ANSI color codes. It works on XTerm, ETerm, Mindterm, etc. It also works on Win9x (with ANSI.SYS loaded.)
NOTE: It doesn't work on WinNT's COMMAND.COM even with ANSI.SYS loaded.
The default colors used for differentiating the message levels can be changed by editing the /org/apache/tools/ant/listener/defaults.properties file. This file contains 5 key/value pairs:
AnsiColorLogger.ERROR_COLOR=2;31 AnsiColorLogger.WARNING_COLOR=2;35 AnsiColorLogger.INFO_COLOR=2;36 AnsiColorLogger.VERBOSE_COLOR=2;32 AnsiColorLogger.DEBUG_COLOR=2;34
Another option is to pass a system variable named ant.logger.defaults, with value set to the path of the file that contains user defined Ansi Color Codes, to the java command using -D option.
To change these colors use the following chart:ANSI COLOR LOGGER CONFIGURATION
Format for AnsiColorLogger.*= Attribute;Foreground;Background Attribute is one of the following:0 -> Reset All Attributes (return to normal mode) 1 -> Bright (Usually turns on BOLD) 2 -> Dim 3 -> Underline 5 -> link 7 -> Reverse 8 -> HiddenForeground is one of the following:
30 -> Black 31 -> Red 32 -> Green 33 -> Yellow 34 -> Blue 35 -> Magenta 36 -> Cyan 37 -> WhiteBackground is one of the following:
40 -> Black 41 -> Red 42 -> Green 43 -> Yellow 44 -> Blue 45 -> Magenta 46 -> Cyan 47 -> White
-
Field Summary
Fields inherited from class org.apache.tools.ant.DefaultLogger
emacsMode, err, LEFT_COLUMN_SIZE, lSep, msgOutputLevel, out
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
printMessage
(String message, PrintStream stream, int priority) Prints a message to a PrintStream.Methods inherited from class org.apache.tools.ant.DefaultLogger
buildFinished, buildStarted, extractProjectName, formatTime, getBuildFailedMessage, getBuildSuccessfulMessage, getMessageOutputLevel, getTimestamp, log, messageLogged, setEmacsMode, setErrorPrintStream, setMessageOutputLevel, setOutputPrintStream, targetFinished, targetStarted, taskFinished, taskStarted
-
Constructor Details
-
AnsiColorLogger
public AnsiColorLogger()
-
-
Method Details
-
printMessage
Description copied from class:DefaultLogger
Prints a message to a PrintStream.- Overrides:
printMessage
in classDefaultLogger
- Parameters:
message
- The message to print. Should not benull
.stream
- A PrintStream to print the message to. Must not benull
.priority
- The priority of the message. (Ignored in this implementation.)- See Also:
-