# listener/AnsiColorLogger.php

## \AnsiColorLogger
jump to top

Package: phing\listener

Uses ANSI Color Code Sequences to colorize messages sent to the console.

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 phing/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:

     <B>ANSI COLOR LOGGER CONFIGURATION</B>

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 -> Hidden

Foreground is one of the following: 30 -> Black 31 -> Red 32 -> Green 33 -> Yellow 34 -> Blue 35 -> Magenta 36 -> Cyan 37 -> White

Background is one of the following: 40 -> Black 41 -> Red 42 -> Green 43 -> Yellow 44 -> Blue 45 -> Magenta 46 -> Cyan 47 -> White

Parent(s)
  \DefaultLogger
Author
  Hans Lellelid (Phing)
Author
  Magesh Umasankar (Ant)
Version
  $Revision: 526 $

### Constants

`ATTR_NORMAL = 0`

`ATTR_BRIGHT = 1`

`ATTR_DIM = 2`

`ATTR_UNDERLINE = 3`

`ATTR_BLINK = 5`

`ATTR_REVERSE = 7`

`ATTR_HIDDEN = 8`

`FG_BLACK = 30`

`FG_RED = 31`

`FG_GREEN = 32`

`FG_YELLOW = 33`

`FG_BLUE = 34`

`FG_MAGENTA = 35`

`FG_CYAN = 36`

`FG_WHITE = 37`

`BG_BLACK = 40`

`BG_RED = 41`

`BG_GREEN = 42`

`BG_YELLOW = 44`

`BG_BLUE = 44`

`BG_MAGENTA = 45`

`BG_CYAN = 46`

`BG_WHITE = 47`

`PREFIX = "\x1b["`

`SUFFIX = "m"`

`SEPARATOR = ';'`

`END_COLOR = "\x1b[m"`

### Properties

`$colorsSet= 'false'`
Default value `false` Details

Type
  n/a

`$debugColor= ''`
Details

Type
  n/a

`$errColor= ''`
Details

Type
  n/a

`$infoColor= ''`
Details

Type
  n/a

`$verboseColor= ''`
Details

Type
  n/a

`$warnColor= ''`
Details

Type
  n/a

### Methods

`__construct( ) : void`

Construct new AnsiColorLogger Perform initializations that cannot be done in var declarations.

`buildFinished( ) : void`

`buildStarted( ) : void`

`formatTime( ) : void`
static

`getBuildFailedMessage( ) : void`

`getBuildSuccessfulMessage( ) : void`

`messageLogged( ) : void`

`printMessage( string $message, \OutputStream $stream, int $priority ) : void`
final

Parameters

Name | Type | Description
--- | --- | ---
$message | string |
$stream | \OutputStream |
$priority | int |

Details

See
  \DefaultLogger#printMessage

`setColors( ) : void`
final

Set the colors to use from a property file specified by the special ant property ant.logger.defaults

`setErrorStream( ) : void`

`setMessageOutputLevel( ) : void`

`setOutputStream( ) : void`

`targetFinished( ) : void`

`targetStarted( ) : void`

`taskFinished( ) : void`

`taskStarted( ) : void`

Documentation was generated by DocBlox 0.17.1.