Package org.apache.tools.ant.listener
Class CommonsLoggingListener
java.lang.Object
org.apache.tools.ant.listener.CommonsLoggingListener
- All Implemented Interfaces:
EventListener
,BuildListener
,BuildLogger
Jakarta Commons Logging listener.
Note: do not use the SimpleLog as your logger implementation as it
causes an infinite loop since it writes to System.err, which Ant traps
and reroutes to the logger/listener layer.
The following names are used for the log:
org.apache.tools.ant.Project.PROJECT_NAME - for project events
org.apache.tools.ant.Target.TARGET_NAME - for target events
TASK_CLASS_NAME.TARGET_NAME - for events in individual targets.
In all target and project names we replace "." and " " with "-".
TODO: we should use the advanced context logging features (and expose them
in c-l first :-)
TODO: this is _very_ inefficient. Switching the out and tracking the logs
can be optimized a lot - but may require few more changes to the core.
- Since:
- Ant 1.5
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct the listener and make sure that a LogFactory can be obtained. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildFinished
(BuildEvent event) Signals that the last target has finished.void
buildStarted
(BuildEvent event) Signals that a build has started.int
void
messageLogged
(BuildEvent event) Signals a message logging event.void
setEmacsMode
(boolean emacsMode) Set emacs mode.void
Set the error print stream.void
setMessageOutputLevel
(int level) Set the the output level.void
setOutputPrintStream
(PrintStream output) Set the output print stream.void
targetFinished
(BuildEvent event) Signals that a target has finished.void
targetStarted
(BuildEvent event) Signals that a target is starting.void
taskFinished
(BuildEvent event) Signals that a task has finished.void
taskStarted
(BuildEvent event) Signals that a task is starting.
-
Field Details
-
TARGET_LOG
name of the category under which target events are logged- See Also:
-
PROJECT_LOG
name of the category under which project events are logged- See Also:
-
-
Constructor Details
-
CommonsLoggingListener
public CommonsLoggingListener()Construct the listener and make sure that a LogFactory can be obtained.
-
-
Method Details
-
buildStarted
Signals that a build has started. This event is fired before any targets have started.This event is fired before the project instance is fully configured. In particular no properties have been set and the project may not know its name or default target, yet.
.- Specified by:
buildStarted
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.
-
buildFinished
Signals that the last target has finished. This event will still be fired if an error occurred during the build..- Specified by:
buildFinished
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
targetStarted
Description copied from interface:BuildListener
Signals that a target is starting.- Specified by:
targetStarted
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
targetFinished
Description copied from interface:BuildListener
Signals that a target has finished. This event will still be fired if an error occurred during the build.- Specified by:
targetFinished
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
taskStarted
Description copied from interface:BuildListener
Signals that a task is starting.- Specified by:
taskStarted
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
taskFinished
Description copied from interface:BuildListener
Signals that a task has finished. This event will still be fired if an error occurred during the build.- Specified by:
taskFinished
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
messageLogged
Description copied from interface:BuildListener
Signals a message logging event.- Specified by:
messageLogged
in interfaceBuildListener
- Parameters:
event
- An event with any relevant extra information. Must not benull
.- See Also:
-
setMessageOutputLevel
public void setMessageOutputLevel(int level) Set the the output level. This is not used, the logger config is used instead.- Specified by:
setMessageOutputLevel
in interfaceBuildLogger
- Parameters:
level
- ignored
-
getMessageOutputLevel
public int getMessageOutputLevel()- Specified by:
getMessageOutputLevel
in interfaceBuildLogger
- Returns:
- Returns the
currently set
message output level. Thedefault
implementation of this method returnsMSG_INFO
.
-
setOutputPrintStream
Set the output print stream.- Specified by:
setOutputPrintStream
in interfaceBuildLogger
- Parameters:
output
- the output stream
-
setEmacsMode
public void setEmacsMode(boolean emacsMode) Set emacs mode. This is ignored.- Specified by:
setEmacsMode
in interfaceBuildLogger
- Parameters:
emacsMode
- ignored
-
setErrorPrintStream
Set the error print stream.- Specified by:
setErrorPrintStream
in interfaceBuildLogger
- Parameters:
err
- the error stream
-