listener/AnsiColorLogger.php

Show: inherited
Table of Contents

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 (Phing)  
Author
Magesh Umasankar (Ant)  
Package
phing.listener  
Version
$Id$  

\AnsiColorLogger

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 < \StreamRequiredBuildLogger < \BuildLogger < \BuildListener
Author
Hans Lellelid (Phing)  
Author
Magesh Umasankar (Ant)  
Copyright
2001,2002 THYRELL. All rights reserved  
Version
$Id$  

Constants

Constant  ATTR_NORMAL = 0
Constant  ATTR_BRIGHT = 1
Constant  ATTR_DIM = 2
Constant  ATTR_UNDERLINE = 3
Constant  ATTR_BLINK = 5
Constant  ATTR_REVERSE = 7
Constant  ATTR_HIDDEN = 8
Constant  FG_BLACK = 30
Constant  FG_RED = 31
Constant  FG_GREEN = 32
Constant  FG_YELLOW = 33
Constant  FG_BLUE = 34
Constant  FG_MAGENTA = 35
Constant  FG_CYAN = 36
Constant  FG_WHITE = 37
Constant  BG_BLACK = 40
Constant  BG_RED = 41
Constant  BG_GREEN = 42
Constant  BG_YELLOW = 44
Constant  BG_BLUE = 44
Constant  BG_MAGENTA = 45
Constant  BG_CYAN = 46
Constant  BG_WHITE = 47
Constant  PREFIX = "\x1b["
Constant  SUFFIX = "m"
Constant  SEPARATOR = ';'
Constant  END_COLOR = "\x1b[m"
Constant  LEFT_COLUMN_SIZE = 12
inherited

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

Inherited from: \DefaultLogger::LEFT_COLUMN_SIZE

@var int

Inherited_from
\DefaultLogger::LEFT_COLUMN_SIZE  

Properties

Propertyprivate  $colorsSet= 'false'
Default valuefalseDetails
Type
n/a
Propertyprivate  $debugColor= ''
Details
Type
n/a
Propertyprotected\OutputStream  $err= ''
inherited

Stream to use for error output.Inherited from: \DefaultLogger::$$err
Details
Type
\OutputStream
Inherited_from
\DefaultLogger::$$err  
Propertyprivate  $errColor= ''
Details
Type
n/a
Propertyprivate  $infoColor= ''
Details
Type
n/a
Propertyprotected  $msgOutputLevel= 'Project::MSG_ERR'
inherited

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

Inherited from: \DefaultLogger::$$msgOutputLevel

@var int

Default valueProject::MSG_ERRDetails
Type
n/a
Inherited_from
\DefaultLogger::$$msgOutputLevel  
Propertyprotected\OutputStream  $out= ''
inherited

Stream to use for standard output.Inherited from: \DefaultLogger::$$out
Details
Type
\OutputStream
Inherited_from
\DefaultLogger::$$out  
Propertyprotected  $startTime= ''
inherited

Time that the build started

Inherited from: \DefaultLogger::$$startTime

@var int

Details
Type
n/a
Inherited_from
\DefaultLogger::$$startTime  
Propertyprivate  $verboseColor= ''
Details
Type
n/a
Propertyprivate  $warnColor= ''
Details
Type
n/a

Methods

methodpublic__construct( ) : void

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

methodpublicbuildFinished(  $event ) : void
inherited

Prints whether the build succeeded or failed, and any errors that occured during the build. Also outputs the total build-time.

Inherited from: \DefaultLogger::buildFinished()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
See
\BuildEvent::getException()  
methodpublicbuildStarted(  $event ) : void
inherited

Sets the start-time when the build started. Used for calculating the build-time.

Inherited from: \DefaultLogger::buildStarted()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
Access
public  
methodpublicformatTime(  $micros ) : void
staticinherited

Formats a time micro integer to human readable format.

Inherited from: \DefaultLogger::formatTime()

@param integer The time stamp

Parameters
Name Type Description
$micros
Details
Access
private  
methodprotectedgetBuildFailedMessage( ) : string
inherited

Get the message to return when a build failed.

Inherited from: \DefaultLogger::getBuildFailedMessage()
Returns
Type Description
string The classic "BUILD FAILED"
methodprotectedgetBuildSuccessfulMessage( ) : string
inherited

Get the message to return when a build succeeded.

Inherited from: \DefaultLogger::getBuildSuccessfulMessage()
Returns
Type Description
string The classic "BUILD FINISHED"
methodpublicmessageLogged(  $event ) : void
inherited

Print a message to the stdout.

Inherited from: \DefaultLogger::messageLogged()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
Access
public  
See
\BuildEvent::getMessage()  
methodprotectedprintMessage( string $message, \OutputStream $stream, int $priority ) : void
final

Prints a message to console.

Parameters
Name Type Description
$message string
$stream \OutputStream
$priority int
Details
See
\DefaultLogger#printMessage  
methodprivatesetColors( ) : void
final

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

methodpublicsetErrorStream( \OutputStream $err ) : void
inherited

Sets the error stream.

Inherited from: \DefaultLogger::setErrorStream()
Parameters
Name Type Description
$err \OutputStream
Details
See
\BuildLogger#setErrorStream()  
methodpublicsetMessageOutputLevel( int $level ) : void
inherited

Set the msgOutputLevel this logger is to respond to.

Inherited from: \DefaultLogger::setMessageOutputLevel()

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

<

p> 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.

Parameters
Name Type Description
$level int

The logging level for the logger.

Details
See
\BuildLogger#setMessageOutputLevel()  
methodpublicsetOutputStream( \OutputStream $output ) : void
inherited

Sets the output stream.

Inherited from: \DefaultLogger::setOutputStream()
Parameters
Name Type Description
$output \OutputStream
Details
See
\BuildLogger#setOutputStream()  
methodpublictargetFinished(  $event ) : void
inherited

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

Inherited from: \DefaultLogger::targetFinished()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
See
\BuildEvent::getException()  
methodpublictargetStarted(  $event ) : void
inherited

Prints the current target name

Inherited from: \DefaultLogger::targetStarted()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
Access
public  
See
\BuildEvent::getTarget()  
methodpublictaskFinished(  $event ) : void
inherited

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

Inherited from: \DefaultLogger::taskFinished()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
Access
public  
See
\BuildEvent::getException()  
methodpublictaskStarted(  $event ) : void
inherited

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

Inherited from: \DefaultLogger::taskStarted()

@param object The BuildEvent

Parameters
Name Type Description
$event
Details
Access
public  
See
\BuildEvent::getTask()  
Documentation was generated by DocBlox 0.18.1.