XmlLogger (Apache Ant API)

Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant
Class XmlLogger

    java.lang.Object
      org.apache.tools.ant.XmlLogger

All Implemented Interfaces:
  java.util.EventListener, BuildListener, BuildLogger

    public class XmlLogger

extends java.lang.Object
implements BuildLogger

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`. This implementation assumes in its sanity checking that only one thread runs a particular target/task at a time. This is enforced by the way that parallel builds and antcalls are done - and indeed all but the simplest of tasks could run into problems if executed in parallel.

See Also:
  `Project.addBuildListener(BuildListener)`

Constructor Summary
`XmlLogger()` Constructs a new BuildListener that logs build events to an XML file.

Method Summary
`void` | `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.
`void` | `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.
`void` | `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.
`void` | `setEmacsMode(boolean emacsMode)` Ignore emacs mode, as it has no meaning in XML format
`void` | `setErrorPrintStream(java.io.PrintStream err)` Ignore error print stream.
`void` | `setMessageOutputLevel(int level)` Set the logging level when using this as a Logger
`void` | `setOutputPrintStream(java.io.PrintStream output)` Set the output stream to which logging output is sent when operating as a logger.
`void` | `targetFinished(BuildEvent event)` Fired when a target finishes building, this adds the time taken and any error stacktrace to the appropriate target element in the log.
`void` | `targetStarted(BuildEvent event)` Fired when a target starts building, this pushes a timed element for the target onto the stack of elements for the current thread, remembering the current time and the name of the target.
`void` | `taskFinished(BuildEvent event)` Fired when a task finishes building, this adds the time taken and any error stacktrace to the appropriate task element in the log.
`void` | `taskStarted(BuildEvent event)` Fired when a task starts building, this pushes a timed element for the task onto the stack of elements for the current thread, remembering the current time and the name of the task.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlLogger

    public XmlLogger()

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

Method Detail

### buildStarted

    public void 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.

  Specified by:
    `buildStarted` in interface `BuildListener`
  Parameters:
    `event` - Ignored.

### buildFinished

    public void 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.

  Specified by:
    `buildFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getException()`

### targetStarted

    public void targetStarted(BuildEvent event)

  Fired when a target starts building, this pushes a timed element for the target onto the stack of elements for the current thread, remembering the current time and the name of the target.

  Specified by:
    `targetStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getTarget()`

### targetFinished

    public void targetFinished(BuildEvent event)

  Fired when a target finishes building, this adds the time taken and any error stacktrace to the appropriate target element in the log.

  Specified by:
    `targetFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getException()`

### taskStarted

    public void taskStarted(BuildEvent event)

  Fired when a task starts building, this pushes a timed element for the task onto the stack of elements for the current thread, remembering the current time and the name of the task.

  Specified by:
    `taskStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getTask()`

### taskFinished

    public void taskFinished(BuildEvent event)

  Fired when a task finishes building, this adds the time taken and any error stacktrace to the appropriate task element in the log.

  Specified by:
    `taskFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getException()`

### messageLogged

    public void 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.

  Specified by:
    `messageLogged` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Will not be `null`.
  See Also:
    `BuildEvent.getMessage()`, `BuildEvent.getException()`, `BuildEvent.getPriority()`

### setMessageOutputLevel

    public void setMessageOutputLevel(int level)

  Set the logging level when using this as a Logger

  Specified by:
    `setMessageOutputLevel` in interface `BuildLogger`
  Parameters:
    `level` - the logging level - see `Project` class for level definitions

### setOutputPrintStream

    public void setOutputPrintStream(java.io.PrintStream output)

  Set the output stream to which logging output is sent when operating as a logger.

  Specified by:
    `setOutputPrintStream` in interface `BuildLogger`
  Parameters:
    `output` - the output PrintStream.

### setEmacsMode

    public void setEmacsMode(boolean emacsMode)

  Ignore emacs mode, as it has no meaning in XML format

  Specified by:
    `setEmacsMode` in interface `BuildLogger`
  Parameters:
    `emacsMode` - true if logger should produce emacs compatible output

### setErrorPrintStream

    public void setErrorPrintStream(java.io.PrintStream err)

  Ignore error print stream. All output will be written to either the XML log file or the PrintStream provided to setOutputPrintStream

  Specified by:
    `setErrorPrintStream` in interface `BuildLogger`
  Parameters:
    `err` - the stream we are going to ignore.

Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD