# listener/XmlLogger.php

$Id: XmlLogger.php 552 2009-08-29 12:18:13Z mrook $

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software consists of voluntary contributions made by many individuals and is licensed under the LGPL. For more information please see http://phing.info.

## \XmlLogger
jump to top

Package: phing\listener

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
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::MSG_DEBUG'`

Default value `Project::MSG_DEBUG` 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( ) : void`

Constructs a new BuildListener that logs build events to an XML file.

`buildFinished( \BuildEvent $event ) : void`

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 ) : void`

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 ) : void`

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 ) : void`

Sets the error stream.

Parameters

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

Details

See
  \BuildLogger#setErrorStream()

`setMessageOutputLevel( int $level ) : void`

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 ) : void`

Sets the output stream.

Parameters

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

Details

See
  \BuildLogger#setOutputStream()

`targetFinished( \BuildEvent $event ) : void`

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 ) : void`

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 ) : void`

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 ) : void`

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