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.
Project#addBuildListener(BuildListener)
Modifier and Type | Class and Description |
---|---|
private static class | XmlLogger.TimedElement
Utility class representing the time an element started. |
Modifier and Type | Field and Description |
---|---|
private static final String | BUILD_TAG
XML element name for a build. |
private XmlLogger. | buildElement
When the build started. |
private static DocumentBuilder | builder
DocumentBuilder to use when creating the document to start with. |
private Document | doc
The complete log document for this build. |
private static final String | ERROR_ATTR
XML attribute name for an error description. |
private static final String | LOCATION_ATTR
XML attribute name for a file location. |
private static final String | MESSAGE_TAG
XML element name for a message. |
private int | |
private static final String | NAME_ATTR
XML attribute name for a name. |
private PrintStream | |
private static final String | PRIORITY_ATTR
XML attribute name for a message priority. |
private static final String | STACKTRACE_TAG
XML element name for a stack trace. |
private static final String | TARGET_TAG
XML element name for a target. |
private Map | targets
Mapping for when targets started (Target to TimedElement). |
private static final String | TASK_TAG
XML element name for a task. |
private Map | tasks
Mapping for when tasks started (Task to TimedElement). |
private Map | threadStacks
Mapping of threads to stacks of elements (Thread to Stack of TimedElement). |
private static final String | TIME_ATTR
XML attribute name for a time. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | buildFinished(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
public void | buildStarted(BuildEvent
Ignored. event)Implements org. |
private static DocumentBuilder | Returns: a default DocumentBuilder instance.Returns a default DocumentBuilder instance or throws an ExceptionInInitializerError if it can't be created. |
public int | |
private String | |
private Stack | Returns: the stack of timed elements for the current threadReturns the stack of timed elements for the current thread. |
private XmlLogger. | |
public void | messageLogged(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
public void | setEmacsMode(boolean
true if logger should produce emacs compatible
output emacsMode)Implements org. |
public void | setErrorPrintStream(PrintStream
the stream we are going to ignore. err)Implements org. |
public void | setMessageOutputLevel(int
the logging level -
see level)Project
class for level definitionsImplements org. |
public void | setOutputPrintStream(PrintStream
the output PrintStream. output)Implements org. |
private void | |
public void | targetFinished(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
public void | targetStarted(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
public void | taskFinished(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
public void | taskStarted(BuildEvent
An event with any relevant extra information.
Will not be event)null .Implements org. |
BUILD_TAG | back to summary |
---|---|
private static final String BUILD_TAG XML element name for a build. |
buildElement | back to summary |
---|---|
private XmlLogger. When the build started. |
builder | back to summary |
---|---|
private static DocumentBuilder builder DocumentBuilder to use when creating the document to start with. |
doc | back to summary |
---|---|
private Document doc The complete log document for this build. |
ERROR_ATTR | back to summary |
---|---|
private static final String ERROR_ATTR XML attribute name for an error description. |
LOCATION_ATTR | back to summary |
---|---|
private static final String LOCATION_ATTR XML attribute name for a file location. |
MESSAGE_TAG | back to summary |
---|---|
private static final String MESSAGE_TAG XML element name for a message. |
msgOutputLevel | back to summary |
---|---|
private int msgOutputLevel |
NAME_ATTR | back to summary |
---|---|
private static final String NAME_ATTR XML attribute name for a name. |
outStream | back to summary |
---|---|
private PrintStream outStream |
PRIORITY_ATTR | back to summary |
---|---|
private static final String PRIORITY_ATTR XML attribute name for a message priority. |
STACKTRACE_TAG | back to summary |
---|---|
private static final String STACKTRACE_TAG XML element name for a stack trace. |
TARGET_TAG | back to summary |
---|---|
private static final String TARGET_TAG XML element name for a target. |
targets | back to summary |
---|---|
private Map<Target, XmlLogger. Mapping for when targets started (Target to TimedElement). |
TASK_TAG | back to summary |
---|---|
private static final String TASK_TAG XML element name for a task. |
tasks | back to summary |
---|---|
private Map<Task, XmlLogger. Mapping for when tasks started (Task to TimedElement). |
threadStacks | back to summary |
---|---|
private Map<Thread, Stack<XmlLogger. Mapping of threads to stacks of elements (Thread to Stack of TimedElement). |
TIME_ATTR | back to summary |
---|---|
private static final String TIME_ATTR XML attribute name for a time. |
XmlLogger | back to summary |
---|---|
public XmlLogger() |
buildFinished | back to summary |
---|---|
public void buildFinished(BuildEvent event) Implements org. Fired when the build finishes, this adds the time taken and any error stacktrace to the build element and writes the document to disk.
|
buildStarted | back to summary |
---|---|
public void buildStarted(BuildEvent event) Implements org. Fired when the build starts, this builds the top-level element for the document and remembers the time of the start of the build.
|
getDocumentBuilder | back to summary |
---|---|
private static DocumentBuilder getDocumentBuilder() Returns a default DocumentBuilder instance or throws an ExceptionInInitializerError if it can't be created.
|
getMessageOutputLevel | back to summary |
---|---|
public int getMessageOutputLevel() Overrides default org.
|
getProperty | back to summary |
---|---|
private String getProperty(BuildEvent event, String propertyName, String defaultValue) |
getStack | back to summary |
---|---|
private Stack Returns the stack of timed elements for the current thread.
|
getTaskElement | back to summary |
---|---|
private XmlLogger. Get the TimedElement associated with a task. Where the task is not found directly, search for unknown elements which may be hiding the real task |
messageLogged | back to summary |
---|---|
public void messageLogged(BuildEvent event) Implements org. 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.
|
setEmacsMode | back to summary |
---|---|
public void setEmacsMode(boolean emacsMode) Implements org. Ignore emacs mode, as it has no meaning in XML format
|
setErrorPrintStream | back to summary |
---|---|
public void setErrorPrintStream(PrintStream err) Implements org. Ignore error print stream. All output will be written to either the XML log file or the PrintStream provided to setOutputPrintStream
|
setMessageOutputLevel | back to summary |
---|---|
public void setMessageOutputLevel(int level) Implements org. Set the logging level when using this as a Logger |
setOutputPrintStream | back to summary |
---|---|
public void setOutputPrintStream(PrintStream output) Implements org. Set the output stream to which logging output is sent when operating as a logger.
|
synchronizedAppend | back to summary |
---|---|
private void synchronizedAppend(Node parent, Node child) |
targetFinished | back to summary |
---|---|
public void targetFinished(BuildEvent event) Implements org. Fired when a target finishes building, this adds the time taken and any error stacktrace to the appropriate target element in the log.
|
targetStarted | back to summary |
---|---|
public void targetStarted(BuildEvent event) Implements org. 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.
|
taskFinished | back to summary |
---|---|
public void taskFinished(BuildEvent event) Implements org. Fired when a task finishes building, this adds the time taken and any error stacktrace to the appropriate task element in the log.
|
taskStarted | back to summary |
---|---|
public void taskStarted(BuildEvent event) Implements org. 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.
|
Modifier and Type | Field and Description |
---|---|
private Element | element
Element created at the start time. |
private long | startTime
Start time in milliseconds
(as returned by |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public String |
element | back to summary |
---|---|
private Element element Element created at the start time. |
startTime | back to summary |
---|---|
private long startTime Start time in milliseconds
(as returned by |
TimedElement | back to summary |
---|---|
private TimedElement() |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object. |