# JsonLogger

Extends \XmlLogger

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

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

author | Siad Ardroumli siad.ardroumli@gmail.com
package | phing.listener

### Methods

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

    __construct()

inherited

## Fired when the build finishes, this adds the time taken and any error stacktrace to the build element and writes the document to disk.

    buildFinished(\BuildEvent $event)

inherited

throws |

### Arguments

#### $event

`\BuildEvent`

An event with any relevant extra information. Will not be `null`.

## Fired when the build starts, this builds the top-level element for the document and remembers the time of the start of the build.

    buildStarted(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

## getBuildElement

    getBuildElement() : \DOMElement

inherited

### Response

`\DOMElement`

## getBuildTimerStart

    getBuildTimerStart() : integer

inherited

### Response

`integer`

## getDoc

    getDoc() : \DOMDocument

inherited

### Response

`\DOMDocument`

## getElementStack

    getElementStack() : array

inherited

### Response

`array`

## getErr

    getErr() : \OutputStream

inherited

### Response

`\OutputStream`

## getMsgOutputLevel

    getMsgOutputLevel() : integer

inherited

### Response

`integer`

## getOut

    getOut() : \OutputStream

inherited

### Response

`\OutputStream`

## getOutFilename

    getOutFilename() : string

inherited

### Response

`string`

## getTimesStack

    getTimesStack() : array

inherited

### Response

`array`

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

    messageLogged(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

## setBuildElement

    setBuildElement( $elem)

inherited

### Arguments

#### $elem

``

## 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`

Configured output stream (e.g. STDERR) for errors.

## 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`

Configured output stream (e.g. STDOUT) for standard output.

## Fired when a target finishes building, this adds the time taken to the appropriate target element in the log.

    targetFinished(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

An event with any relevant extra information. Will not be `null`.

## Fired when a target starts building, remembers the current time and the name of the target.

    targetStarted(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

An event with any relevant extra information. Will not be `null`.

## Fired when a task finishes building, this adds the time taken to the appropriate task element in the log.

    taskFinished(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

An event with any relevant extra information. Will not be `null`.

## Fired when a task starts building, remembers the current time and the name of the task.

    taskStarted(\BuildEvent $event)

inherited

### Arguments

#### $event

`\BuildEvent`

An event with any relevant extra information. Will not be `null`.

## xml2js

    xml2js(\SimpleXMLElement $xmlnode,  $isRoot = true)

### Arguments

#### $xmlnode

`\SimpleXMLElement`

#### $isRoot

``

### Constants

## XML element name for a build.

    BUILD_TAG

inherited

## XML element name for a target.

    TARGET_TAG

inherited

## XML element name for a task.

    TASK_TAG

inherited

## XML element name for a message.

    MESSAGE_TAG

inherited

## XML attribute name for a name.

    NAME_ATTR

inherited

## XML attribute name for a time.

    TIME_ATTR

inherited

## XML attribute name for a message priority.

    PRIORITY_ATTR

inherited

## XML attribute name for a file location.

    LOCATION_ATTR

inherited

## XML attribute name for an error description.

    ERROR_ATTR

inherited

## XML element name for a stack trace.

    STACKTRACE_TAG

inherited

### Properties

## The XML document created by this logger.

    doc : \DOMDocument

inherited

var | The XML document created by this logger.

### Type(s)

`\DOMDocument`

## Start time for entire build.

    buildTimerStart : integer

inherited

var | Start time for entire build.

### Type(s)

`integer`

## Top-level (root) build element

    buildElement : \DOMElement

inherited

var | Top-level (root) build element

### Type(s)

`\DOMElement`

## DOMElement[] The parent of the element being processed.

    elementStack : array

inherited

var | DOMElement[] The parent of the element being processed.

### Type(s)

`array`

## int[] Array of millisecond times for the various elements being processed.

    timesStack : array

inherited

var | int[] Array of millisecond times for the various elements being processed.

### Type(s)

`array`

## msgOutputLevel

    msgOutputLevel : 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`

## Name of filename to create.

    outFilename : string

inherited

var | Name of filename to create.

### Type(s)

`string`