# classes/phing/listener/XmlLogger.php

## \XmlLogger
jump to top

Generates a file in the current directory with an XML description of what happened during a build.

The default filename is "log.xml", but this can be overridden with the property `XmlLogger.file`.

Implements
  \BuildLogger
author
  Michiel Rook
package
  phing.listener
version
  $Id: XmlLogger.php 552 2009-08-29 12:18:13Z mrook $

### Constants

`BUILD_TAG = 'build'`

XML element name for a build.

`TARGET_TAG = 'target'`

XML element name for a target.

`TASK_TAG = 'task'`

XML element name for a task.

`MESSAGE_TAG = 'message'`

XML element name for a message.

`NAME_ATTR = 'name'`

XML attribute name for a name.

`TIME_ATTR = 'time'`

XML attribute name for a time.

`PRIORITY_ATTR = 'priority'`

XML attribute name for a message priority.

`LOCATION_ATTR = 'location'`

XML attribute name for a file location.

`ERROR_ATTR = 'error'`

XML attribute name for an error description.

`STACKTRACE_TAG = 'stacktrace'`

XML element name for a stack trace.

### Properties

`\DOMElement $buildElement= ''`

Top-level (root) build element
Details

Type
  \DOMElement

`int $buildTimerStart= '0'`

Start time for entire build.
Default value `0` Details

Type
  int

`\DOMDocument $doc= ''`

The XML document created by this logger.
Details

Type
  \DOMDocument

`array $elementStack= 'array'`

DOMElement[] The parent of the element being processed.
Default value `array` Details

Type
  array

`\OutputStream $err= ''`

Stream to use for error output.
Details

Type
  \OutputStream

`int $msgOutputLevel= 'Project'`

Default value `Project` Details

Type
  int

`\OutputStream $out= ''`

Stream to use for standard output.
Details

Type
  \OutputStream

`string $outFilename= ''`

Name of filename to create.
Details

Type
  string

`array $timesStack= 'array'`

int[] Array of millisecond times for the various elements being processed.
Default value `array` Details

Type
  array

### Methods

`__construct( ) :`
Constructs a new BuildListener that logs build events to an XML file.
`buildFinished( \BuildEvent $event ) :`
Fired when the build finishes, this adds the time taken and any error stacktrace to the build element and writes the document to disk.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

`buildStarted( \BuildEvent $event ) :`
Fired when the build starts, this builds the top-level element for the document and remembers the time of the start of the build.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | Ignored.

`messageLogged( \BuildEvent $event ) :`
Fired when a message is logged, this adds a message element to the most appropriate parent element (task, target or build) and records the priority and text of the message.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

`setErrorStream( \OutputStream $err ) :`
Sets the error stream.
Parameters

Name | Type | Description
--- | --- | ---
$err | \OutputStream |

Details

see
  \BuildLogger#setErrorStream()

`setMessageOutputLevel( int $level ) :`
Set the msgOutputLevel this logger is to respond to.

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()

`setOutputStream( \OutputStream $output ) :`
Sets the output stream.
Parameters

Name | Type | Description
--- | --- | ---
$output | \OutputStream |

Details

see
  \BuildLogger#setOutputStream()

`targetFinished( \BuildEvent $event ) :`
Fired when a target finishes building, this adds the time taken to the appropriate target element in the log.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

`targetStarted( \BuildEvent $event ) :`
Fired when a target starts building, remembers the current time and the name of the target.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

`taskFinished( \BuildEvent $event ) :`
Fired when a task finishes building, this adds the time taken to the appropriate task element in the log.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

`taskStarted( \BuildEvent $event ) :`
Fired when a task starts building, remembers the current time and the name of the task.
Parameters

Name | Type | Description
--- | --- | ---
$event | \BuildEvent | An event with any relevant extra information. Will not be `null`.

Documentation was generated by DocBlox 0.13.1.