Package org.apache.tools.ant
Class DefaultLogger
- java.lang.Object
- 
- org.apache.tools.ant.DefaultLogger
 
- 
- All Implemented Interfaces:
- java.util.EventListener,- BuildListener,- BuildLogger
 - Direct Known Subclasses:
- AnsiColorLogger,- MailLogger,- NoBannerLogger,- ProfileLogger,- SilentLogger,- TimestampedLogger
 
 public class DefaultLogger extends java.lang.Object implements BuildLogger Writes build events to a PrintStream. Currently, it only writes which targets are being executed, and any messages that get logged.
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanemacsModeWhether or not to use emacs-style outputprotected java.io.PrintStreamerrPrintStream to write error messages tostatic intLEFT_COLUMN_SIZESize of left-hand column for right-justified task name.protected static java.lang.StringlSepDeprecated.protected intmsgOutputLevelLowest level of message to write outprotected java.io.PrintStreamoutPrintStream to write non-error messages to
 - 
Constructor SummaryConstructors Constructor Description DefaultLogger()Sole constructor.
 - 
Method SummaryModifier and Type Method Description voidbuildFinished(BuildEvent event)Prints whether the build succeeded or failed, any errors the occurred during the build, and how long the build took.voidbuildStarted(BuildEvent event)Responds to a build being started by just remembering the current time.protected java.lang.StringextractProjectName(BuildEvent event)Get the project name or nullprotected static java.lang.StringformatTime(long millis)Convenience method to format a specified length of time.protected java.lang.StringgetBuildFailedMessage()This is an override point: the message that indicates whether a build failed.protected java.lang.StringgetBuildSuccessfulMessage()This is an override point: the message that indicates that a build succeeded.protected java.lang.StringgetTimestamp()Get the current time.protected voidlog(java.lang.String message)Empty implementation which allows subclasses to receive the same output that is generated here.voidmessageLogged(BuildEvent event)Logs a message, if the priority is suitable.protected voidprintMessage(java.lang.String message, java.io.PrintStream stream, int priority)Prints a message to a PrintStream.voidsetEmacsMode(boolean emacsMode)Sets this logger to produce emacs (and other editor) friendly output.voidsetErrorPrintStream(java.io.PrintStream err)Sets the output stream to which this logger is to send error messages.voidsetMessageOutputLevel(int level)Sets the highest level of message this logger should respond to.voidsetOutputPrintStream(java.io.PrintStream output)Sets the output stream to which this logger is to send its output.voidtargetFinished(BuildEvent event)No-op implementation.voidtargetStarted(BuildEvent event)Logs a message to say that the target has started if this logger allows information-level messages.voidtaskFinished(BuildEvent event)No-op implementation.voidtaskStarted(BuildEvent event)No-op implementation.
 
- 
- 
- 
Field Detail- 
LEFT_COLUMN_SIZEpublic static final int LEFT_COLUMN_SIZE Size of left-hand column for right-justified task name.- See Also:
- messageLogged(BuildEvent), Constant Field Values
 
 - 
outprotected java.io.PrintStream out PrintStream to write non-error messages to
 - 
errprotected java.io.PrintStream err PrintStream to write error messages to
 - 
msgOutputLevelprotected int msgOutputLevel Lowest level of message to write out
 - 
lSep@Deprecated protected static final java.lang.String lSep Deprecated.Line separator
 - 
emacsModeprotected boolean emacsMode Whether or not to use emacs-style output
 
- 
 - 
Method Detail- 
setMessageOutputLevelpublic void setMessageOutputLevel(int level) Sets the highest level of message this logger should respond to. Only messages with a message level lower than or equal to the given level should be written to the log.Constants for the message levels are in the Projectclass. The order of the levels, from least to most verbose, isMSG_ERR,MSG_WARN,MSG_INFO,MSG_VERBOSE,MSG_DEBUG.The default message level for DefaultLogger is Project.MSG_ERR. - Specified by:
- setMessageOutputLevelin interface- BuildLogger
- Parameters:
- level- the logging level for the logger.
 
 - 
setOutputPrintStreampublic void setOutputPrintStream(java.io.PrintStream output) Sets the output stream to which this logger is to send its output.- Specified by:
- setOutputPrintStreamin interface- BuildLogger
- Parameters:
- output- The output stream for the logger. Must not be- null.
 
 - 
setErrorPrintStreampublic void setErrorPrintStream(java.io.PrintStream err) Sets the output stream to which this logger is to send error messages.- Specified by:
- setErrorPrintStreamin interface- BuildLogger
- Parameters:
- err- The error stream for the logger. Must not be- null.
 
 - 
setEmacsModepublic void setEmacsMode(boolean emacsMode) Sets this logger to produce emacs (and other editor) friendly output.- Specified by:
- setEmacsModein interface- BuildLogger
- Parameters:
- emacsMode-- trueif output is to be unadorned so that emacs and other editors can parse files names, etc.
 
 - 
buildStartedpublic void buildStarted(BuildEvent event) Responds to a build being started by just remembering the current time.- Specified by:
- buildStartedin interface- BuildListener
- Parameters:
- event- Ignored.
 
 - 
buildFinishedpublic void buildFinished(BuildEvent event) Prints whether the build succeeded or failed, any errors the occurred during the build, and how long the build took.- Specified by:
- buildFinishedin interface- BuildListener
- Parameters:
- event- An event with any relevant extra information. Must not be- null.
- See Also:
- BuildEvent.getException()
 
 - 
getBuildFailedMessageprotected java.lang.String getBuildFailedMessage() This is an override point: the message that indicates whether a build failed. Subclasses can change/enhance the message.- Returns:
- The classic "BUILD FAILED"
 
 - 
getBuildSuccessfulMessageprotected java.lang.String getBuildSuccessfulMessage() This is an override point: the message that indicates that a build succeeded. Subclasses can change/enhance the message.- Returns:
- The classic "BUILD SUCCESSFUL"
 
 - 
targetStartedpublic void targetStarted(BuildEvent event) Logs a message to say that the target has started if this logger allows information-level messages.- Specified by:
- targetStartedin interface- BuildListener
- Parameters:
- event- An event with any relevant extra information. Must not be- null.
- See Also:
- BuildEvent.getTarget()
 
 - 
targetFinishedpublic void targetFinished(BuildEvent event) No-op implementation.- Specified by:
- targetFinishedin interface- BuildListener
- Parameters:
- event- Ignored.
- See Also:
- BuildEvent.getException()
 
 - 
taskStartedpublic void taskStarted(BuildEvent event) No-op implementation.- Specified by:
- taskStartedin interface- BuildListener
- Parameters:
- event- Ignored.
- See Also:
- BuildEvent.getTask()
 
 - 
taskFinishedpublic void taskFinished(BuildEvent event) No-op implementation.- Specified by:
- taskFinishedin interface- BuildListener
- Parameters:
- event- Ignored.
- See Also:
- BuildEvent.getException()
 
 - 
messageLoggedpublic void messageLogged(BuildEvent event) Logs a message, if the priority is suitable. In non-emacs mode, task level messages are prefixed by the task name which is right-justified.- Specified by:
- messageLoggedin interface- BuildListener
- Parameters:
- event- A BuildEvent containing message information. Must not be- null.
- See Also:
- BuildEvent.getMessage(),- BuildEvent.getException(),- BuildEvent.getPriority()
 
 - 
formatTimeprotected static java.lang.String formatTime(long millis) Convenience method to format a specified length of time.- Parameters:
- millis- Length of time to format, in milliseconds.
- Returns:
- the time as a formatted string.
- See Also:
- DateUtils.formatElapsedTime(long)
 
 - 
printMessageprotected void printMessage(java.lang.String message, java.io.PrintStream stream, int priority)Prints a message to a PrintStream.- Parameters:
- message- The message to print. Should not be- null.
- stream- A PrintStream to print the message to. Must not be- null.
- priority- The priority of the message. (Ignored in this implementation.)
 
 - 
logprotected void log(java.lang.String message) Empty implementation which allows subclasses to receive the same output that is generated here.- Parameters:
- message- Message being logged. Should not be- null.
 
 - 
getTimestampprotected java.lang.String getTimestamp() Get the current time.- Returns:
- the current time as a formatted string.
- Since:
- Ant1.7.1
 
 - 
extractProjectNameprotected java.lang.String extractProjectName(BuildEvent event) Get the project name or null- Parameters:
- event- the event
- Returns:
- the project that raised this event
- Since:
- Ant1.7.1
 
 
- 
 
-