# AnsiColorLogger

Extends \DefaultLogger

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

author | Hans Lellelid hans@xmpl.org (Phing)
author | Magesh Umasankar (Ant)
package | phing.listener
version | $Id: eccc8da05ad1fbe73d38da7fca7ecb4816beabd0 $

### Methods

## Construct a new default logger.

    __construct()

inherited

## Formats a time micro integer to human readable format.

    formatTime( $micros) : string

inherited static

### Arguments

#### $micros

``

### Response

`string`

## Get the message to return when a build failed.

    getBuildFailedMessage() : string

inherited

### Response

`string`

The classic "BUILD FAILED"

## Get the message to return when a build succeeded.

    getBuildSuccessfulMessage() : string

inherited

### Response

`string`

The classic "BUILD FINISHED"

## Print a message to the stdout.

    messageLogged(\BuildEvent $event)

inherited

see | \BuildEvent::getMessage()

### Arguments

#### $event

`\BuildEvent`

## Prints a message to console.

    printMessage(string $message, \OutputStream|resource $stream, integer $priority) : void

inherited

throws |

### Arguments

#### $message

`string`

The message to print. Should not be `null`.

#### $stream

`\OutputStream|resource`

The stream to use for message printing.

#### $priority

`integer`

The priority of the message. (Ignored in this implementation.)

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

    setColors()

final

## Sets this logger to produce emacs (and other editor) friendly output.

    setEmacsMode(boolean $emacsMode)

inherited

### Arguments

#### $emacsMode

`boolean`

`true` if output is to be unadorned so that emacs and other editors can parse files names, etc.

## Sets the error stream.

    setErrorStream(\OutputStream $err)

inherited

see | \BuildLogger#setErrorStream()

### Arguments

#### $err

`\OutputStream`

## Set the msgOutputLevel this logger is to respond to.

    setMessageOutputLevel(integer $level)

inherited

Only messages with a message level lower than or equal to the given level are output to the log.

Constants for the message levels are in Project.php. The order of the levels, from least to most verbose, is:

- Project::MSG_ERR
- Project::MSG_WARN
- Project::MSG_INFO
- Project::MSG_VERBOSE
- Project::MSG_DEBUG

The default message level for DefaultLogger is Project::MSG_ERR.

see | \BuildLogger#setMessageOutputLevel()

### Arguments

#### $level

`integer`

The logging level for the logger.

## Sets the output stream.

    setOutputStream(\OutputStream $output)

inherited

see | \BuildLogger#setOutputStream()

### Arguments

#### $output

`\OutputStream`

## Fired when a task has finished. We don't need specific action on this event. So the methods are empty.

    taskFinished(\BuildEvent $event)

inherited

see | \BuildEvent::getException()

### Arguments

#### $event

`\BuildEvent`

The BuildEvent

### Constants

## ATTR_NORMAL

    ATTR_NORMAL

## ATTR_BRIGHT

    ATTR_BRIGHT

## ATTR_DIM

    ATTR_DIM

## ATTR_UNDERLINE

    ATTR_UNDERLINE

## ATTR_BLINK

    ATTR_BLINK

## ATTR_REVERSE

    ATTR_REVERSE

## ATTR_HIDDEN

    ATTR_HIDDEN

## FG_BLACK

    FG_BLACK

## FG_RED

    FG_RED

## FG_GREEN

    FG_GREEN

## FG_YELLOW

    FG_YELLOW

## FG_BLUE

    FG_BLUE

## FG_MAGENTA

    FG_MAGENTA

## FG_CYAN

    FG_CYAN

## FG_WHITE

    FG_WHITE

## BG_BLACK

    BG_BLACK

## BG_RED

    BG_RED

## BG_GREEN

    BG_GREEN

## BG_YELLOW

    BG_YELLOW

## BG_BLUE

    BG_BLUE

## BG_MAGENTA

    BG_MAGENTA

## BG_CYAN

    BG_CYAN

## BG_WHITE

    BG_WHITE

## PREFIX

    PREFIX

## SUFFIX

    SUFFIX

## SEPARATOR

    SEPARATOR

## END_COLOR

    END_COLOR

## Size of the left column in output. The default char width is 12.

    LEFT_COLUMN_SIZE

inherited

var |

### Properties

## errColor

    errColor :

### Type(s)

``

## warnColor

    warnColor :

### Type(s)

``

## infoColor

    infoColor :

### Type(s)

``

## verboseColor

    verboseColor :

### Type(s)

``

## debugColor

    debugColor :

### Type(s)

``

## colorsSet

    colorsSet :

### Type(s)

``

## The message output level that should be used. The default is <code>Project::MSG_VERBOSE</code>.

    msgOutputLevel : integer

inherited

var |

### Type(s)

`integer`

## Time that the build started

    startTime : integer

inherited

var |

### Type(s)

`integer`

## Stream to use for standard output.

    out : \OutputStream

inherited

var | Stream to use for standard output.

### Type(s)

`\OutputStream`

## Stream to use for error output.

    err : \OutputStream

inherited

var | Stream to use for error output.

### Type(s)

`\OutputStream`

## emacsMode

    emacsMode :

inherited

### Type(s)

``