Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Recorder

extends Task
implements SubBuildListener
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.SubBuildListener, org.apache.tools.ant.BuildListener, java.util.EventListener
Imports
java.util.Hashtable, .Map, org.apache.tools.ant.BuildEvent, .BuildException, .Project, .SubBuildListener, .Task, org.apache.tools.ant.types.EnumeratedAttribute, .LogLevel

Adds a listener to the current build process that records the output to a file.

Several recorders can exist at the same time. Each recorder is associated with a file. The filename is used as a unique identifier for the recorders. The first call to the recorder task with an unused filename will create a recorder (using the parameters provided) and add it to the listeners of the build. All subsequent calls to the recorder task using this filename will modify that recorders state (recording or not) or other properties (like logging level).

Some technical issues: the file's print stream is flushed for "finished" events (buildFinished, targetFinished and taskFinished), and is closed on a buildFinished event.

Since
Ant 1.4
Version
0.5
See Also
RecorderEntry

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Recorder.ActionChoices

A list of possible values for the setAction() method.

public static class
Recorder.VerbosityLevelChoices

A list of possible values for the setLoglevel() method.

Field Summary

Modifier and TypeField and Description
private Boolean
append

Whether or not to append.

private boolean
emacsMode

Strip task banners if true.

private String
filename

The name of the file to record to.

private int
loglevel

The level to log at.

private static Map<String, RecorderEntry>
recorderEntries

The list of recorder entries.

private Boolean
start

Whether to start or stop recording.

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
buildFinished(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.buildFinished.

Cleans recorder registry.
public void
buildStarted(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.buildStarted.

Empty implementation required by SubBuildListener interface.
private void
cleanup()

cleans recorder registry and removes itself from BuildListener list.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

The main execution.
protected RecorderEntry

Returns:

a recorder
getRecorder
(String
the name of the recorder
name
,
Project
the current project
proj
)

Gets the recorder that's associated with the passed in name.

public void
init()

Overrides org.apache.tools.ant.Task.init.

Overridden so we can add the task as build listener.
public void
messageLogged(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.messageLogged.

Empty implementation required by SubBuildListener interface.
public void
setAction(Recorder.ActionChoices
The action for the entry to take: start or stop.
action
)

Sets the action for the associated recorder entry.

public void
setAppend(boolean
if true, append to a previous file.
append
)

Whether or not the logger should append to a previous file.

public void
setEmacsMode(boolean
if true use emacs mode
emacsMode
)

Set emacs mode.

public void
setLoglevel(Recorder.VerbosityLevelChoices
the level to set.
level
)

Sets the level to which this recorder entry should log to.

public void
setLogLevel(final LogLevel
the level to set.
level
)

Sets the level to which this recorder entry should log to.

public void
setName(String
File name of logfile.
fname
)

Sets the name of the file to log to, and the name of the recorder entry.

public void
subBuildFinished(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.SubBuildListener.subBuildFinished.

Cleans recorder registry, if this is the subbuild the task has been created in.
public void
subBuildStarted(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.SubBuildListener.subBuildStarted.

Empty implementation required by SubBuildListener interface.
public void
targetFinished(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.targetFinished.

Empty implementation required by SubBuildListener interface.
public void
targetStarted(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.targetStarted.

Empty implementation required by SubBuildListener interface.
public void
taskFinished(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.taskFinished.

Empty implementation required by SubBuildListener interface.
public void
taskStarted(BuildEvent
ignored.
event
)

Implements org.apache.tools.ant.BuildListener.taskStarted.

Empty implementation required by SubBuildListener interface.
Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

appendback to summary
private Boolean append

Whether or not to append. Need Boolean to record an unset state (null).

emacsModeback to summary
private boolean emacsMode

Strip task banners if true.

filenameback to summary
private String filename

The name of the file to record to.

loglevelback to summary
private int loglevel

The level to log at. A level of -1 means not initialized yet.

recorderEntriesback to summary
private static Map<String, RecorderEntry> recorderEntries

The list of recorder entries.

startback to summary
private Boolean start

Whether to start or stop recording. Need Boolean to record an unset state (null).

Constructor Detail

Recorderback to summary
public Recorder()

Method Detail

buildFinishedback to summary
public void buildFinished(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.buildFinished.

Cleans recorder registry.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
buildStartedback to summary
public void buildStarted(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.buildStarted.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
cleanupback to summary
private void cleanup()

cleans recorder registry and removes itself from BuildListener list.

Since
Ant 1.7
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

The main execution.

Exceptions
BuildException:
on error
getRecorderback to summary
protected RecorderEntry getRecorder(String name, Project proj) throws BuildException

Gets the recorder that's associated with the passed in name. If the recorder doesn't exist, then a new one is created.

Parameters
name:String

the name of the recorder

proj:Project

the current project

Returns:RecorderEntry

a recorder

Exceptions
BuildException:
on error
initback to summary
public void init()

Overrides org.apache.tools.ant.Task.init.

Overridden so we can add the task as build listener.

Since
Ant 1.7
messageLoggedback to summary
public void messageLogged(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.messageLogged.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
setActionback to summary
public void setAction(Recorder.ActionChoices action)

Sets the action for the associated recorder entry.

Parameters
action:Recorder.ActionChoices

The action for the entry to take: start or stop.

setAppendback to summary
public void setAppend(boolean append)

Whether or not the logger should append to a previous file.

Parameters
append:boolean

if true, append to a previous file.

setEmacsModeback to summary
public void setEmacsMode(boolean emacsMode)

Set emacs mode.

Parameters
emacsMode:boolean

if true use emacs mode

setLoglevelback to summary
public void setLoglevel(Recorder.VerbosityLevelChoices level)

Sets the level to which this recorder entry should log to.

Parameters
level:Recorder.VerbosityLevelChoices

the level to set.

See Also
VerbosityLevelChoices
setLogLevelback to summary
public void setLogLevel(final LogLevel level)

Sets the level to which this recorder entry should log to.

Parameters
level:LogLevel

the level to set.

Since
Ant 1.10.14
setNameback to summary
public void setName(String fname)

Sets the name of the file to log to, and the name of the recorder entry.

Parameters
fname:String

File name of logfile.

subBuildFinishedback to summary
public void subBuildFinished(BuildEvent event)

Implements org.apache.tools.ant.SubBuildListener.subBuildFinished.

Cleans recorder registry, if this is the subbuild the task has been created in.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
subBuildStartedback to summary
public void subBuildStarted(BuildEvent event)

Implements org.apache.tools.ant.SubBuildListener.subBuildStarted.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
targetFinishedback to summary
public void targetFinished(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.targetFinished.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
targetStartedback to summary
public void targetStarted(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.targetStarted.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
taskFinishedback to summary
public void taskFinished(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.taskFinished.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
taskStartedback to summary
public void taskStarted(BuildEvent event)

Implements org.apache.tools.ant.BuildListener.taskStarted.

Empty implementation required by SubBuildListener interface.

Parameters
event:BuildEvent

ignored.

Since
Ant 1.7
org.apache.tools.ant.taskdefs back to summary

public Class Recorder.ActionChoices

extends EnumeratedAttribute
Class Inheritance

A list of possible values for the setAction() method. Possible values include: start and stop.

Field Summary

Modifier and TypeField and Description
private static final String[]
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String[]
getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

This is the only method a subclass needs to implement.
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Field Detail

VALUESback to summary
private static final String[] VALUES

Constructor Detail

ActionChoicesback to summary
public ActionChoices()

Method Detail

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Doc from org.apache.tools.ant.types.EnumeratedAttribute.getValues.

This is the only method a subclass needs to implement.

Returns:String[]

an array holding all possible values of the enumeration. The order of elements must be fixed so that indexOfValue(String) always return the same index for the same value.

See Also
.
org.apache.tools.ant.taskdefs back to summary

public Class Recorder.VerbosityLevelChoices

extends LogLevel
Class Inheritance

A list of possible values for the setLoglevel() method. Possible values include: error, warn, info, verbose, debug.

Field Summary

Inherited from org.apache.tools.ant.types.LogLevel:
DEBUGERRINFOVERBOSEWARN

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.apache.tools.ant.types.LogLevel:
getLevelgetValues

Constructor Detail

VerbosityLevelChoicesback to summary
public VerbosityLevelChoices()