Class Recorder
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.Recorder
- All Implemented Interfaces:
Cloneable, EventListener, BuildListener, SubBuildListener
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA list of possible values for thesetAction()method.static classA list of possible values for thesetLoglevel()method. -
Field Summary
Fields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildFinished(BuildEvent event) Cleans recorder registry.voidbuildStarted(BuildEvent event) Empty implementation required by SubBuildListener interface.voidexecute()The main execution.protected RecorderEntrygetRecorder(String name, Project proj) Gets the recorder that's associated with the passed in name.voidinit()Overridden so we can add the task as build listener.voidmessageLogged(BuildEvent event) Empty implementation required by SubBuildListener interface.voidsetAction(Recorder.ActionChoices action) Sets the action for the associated recorder entry.voidsetAppend(boolean append) Whether or not the logger should append to a previous file.voidsetEmacsMode(boolean emacsMode) Set emacs mode.voidSets the level to which this recorder entry should log to.voidsetLogLevel(LogLevel level) Sets the level to which this recorder entry should log to.voidSets the name of the file to log to, and the name of the recorder entry.voidsubBuildFinished(BuildEvent event) Cleans recorder registry, if this is the subbuild the task has been created in.voidsubBuildStarted(BuildEvent event) Empty implementation required by SubBuildListener interface.voidtargetFinished(BuildEvent event) Empty implementation required by SubBuildListener interface.voidtargetStarted(BuildEvent event) Empty implementation required by SubBuildListener interface.voidtaskFinished(BuildEvent event) Empty implementation required by SubBuildListener interface.voidtaskStarted(BuildEvent event) Empty implementation required by SubBuildListener interface.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProjectModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.voidsetProject(Project project) Sets the project object of this component.
-
Constructor Details
-
Recorder
public Recorder()
-
-
Method Details
-
init
-
setName
Sets the name of the file to log to, and the name of the recorder entry.- Parameters:
fname- File name of logfile.
-
setAction
Sets the action for the associated recorder entry.- Parameters:
action- The action for the entry to take: start or stop.
-
setAppend
public void setAppend(boolean append) Whether or not the logger should append to a previous file.- Parameters:
append- if true, append to a previous file.
-
setEmacsMode
public void setEmacsMode(boolean emacsMode) Set emacs mode.- Parameters:
emacsMode- if true use emacs mode
-
setLoglevel
Sets the level to which this recorder entry should log to.- Parameters:
level- the level to set.- See Also:
-
setLogLevel
Sets the level to which this recorder entry should log to.- Parameters:
level- the level to set.- Since:
- Ant 1.10.14
-
execute
The main execution.- Overrides:
executein classTask- Throws:
BuildException- on error
-
getRecorder
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- the name of the recorderproj- the current project- Returns:
- a recorder
- Throws:
BuildException- on error
-
buildStarted
Empty implementation required by SubBuildListener interface.- Specified by:
buildStartedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
-
subBuildStarted
Empty implementation required by SubBuildListener interface.- Specified by:
subBuildStartedin interfaceSubBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
-
targetStarted
Empty implementation required by SubBuildListener interface.- Specified by:
targetStartedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
targetFinished
Empty implementation required by SubBuildListener interface.- Specified by:
targetFinishedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
taskStarted
Empty implementation required by SubBuildListener interface.- Specified by:
taskStartedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
taskFinished
Empty implementation required by SubBuildListener interface.- Specified by:
taskFinishedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
messageLogged
Empty implementation required by SubBuildListener interface.- Specified by:
messageLoggedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
buildFinished
Cleans recorder registry.- Specified by:
buildFinishedin interfaceBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-
subBuildFinished
Cleans recorder registry, if this is the subbuild the task has been created in.- Specified by:
subBuildFinishedin interfaceSubBuildListener- Parameters:
event- ignored.- Since:
- Ant 1.7
- See Also:
-