org.devaki.nextobjects.util
Class NOBuildLogger

java.lang.Object
  extended byorg.devaki.nextobjects.util.NOBuildLogger
All Implemented Interfaces:
org.apache.tools.ant.BuildListener, org.apache.tools.ant.BuildLogger, java.util.EventListener

public final class NOBuildLogger
extends java.lang.Object
implements org.apache.tools.ant.BuildLogger

Writes build events to a PrintStream.Currently, it only writes which targets are being executed, and any messages that get logged.

Author:
Emmanuel Florent
See Also:
DefaultLogger

Field Summary
static int LEFT_COLUMN_SIZE
          Size of left-hand column for right-justified task name.
 
Constructor Summary
NOBuildLogger()
          Sole constructor Do nothing
 
Method Summary
 void buildFinished(org.apache.tools.ant.BuildEvent event)
          Prints whether the build succeeded or failed, any errors the occured during the build, and how long the build took.
 void buildStarted(org.apache.tools.ant.BuildEvent event)
          Responds to a build being started by just remembering the current time.
protected static java.lang.String formatTime(long millis)
          Convenience method to format a specified length of time.
protected  void log(java.lang.String message)
          Empty implementation which allows subclasses to receive the same output that is generated here.
 void messageLogged(org.apache.tools.ant.BuildEvent event)
          Logs a message, if the priority is suitable.
protected  void printMessage(java.lang.String message, java.io.PrintStream stream, int priority)
          Prints a message to a PrintStream.
 void setEmacsMode(boolean pEmacsMode)
          Sets this logger to produce emacs (and other editor) friendly output.
 void setErrorPrintStream(java.io.PrintStream pErr)
          Sets the output stream to which this logger is to send error messages.
 void setMessageOutputLevel(int level)
          Sets the highest level of message this logger should respond to.
protected  void setMsgOutputLevel(int pMsgOutputLevel)
          Set the log level of the logging panel
 void setOutputPrintStream(java.io.PrintStream output)
          Sets the output stream to which this logger is to send its output.
 void targetFinished(org.apache.tools.ant.BuildEvent event)
          No-op implementation.
 void targetStarted(org.apache.tools.ant.BuildEvent event)
          Logs a message to say that the target has started if this logger allows information-level messages.
 void taskFinished(org.apache.tools.ant.BuildEvent event)
          No-op implementation.
 void taskStarted(org.apache.tools.ant.BuildEvent event)
          No-op implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_COLUMN_SIZE

public static final int LEFT_COLUMN_SIZE
Size of left-hand column for right-justified task name.

See Also:
messageLogged(BuildEvent), Constant Field Values
Constructor Detail

NOBuildLogger

public NOBuildLogger()
Sole constructor Do nothing

Method Detail

setMessageOutputLevel

public final 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 Project class. The order of the levels, from least to most verbose, is MSG_ERR, MSG_WARN, MSG_INFO, MSG_VERBOSE, MSG_DEBUG.

The default message level for DefaultLogger is Project.MSG_ERR.

Specified by:
setMessageOutputLevel in interface org.apache.tools.ant.BuildLogger
Parameters:
level - the logging level for the logger.

setOutputPrintStream

public final void setOutputPrintStream(java.io.PrintStream output)
Sets the output stream to which this logger is to send its output.

Specified by:
setOutputPrintStream in interface org.apache.tools.ant.BuildLogger
Parameters:
output - The output stream for the logger. Must not be null.

setErrorPrintStream

public final void setErrorPrintStream(java.io.PrintStream pErr)
Sets the output stream to which this logger is to send error messages.

Specified by:
setErrorPrintStream in interface org.apache.tools.ant.BuildLogger
Parameters:
pErr - The error stream for the logger. Must not be null.

setEmacsMode

public final void setEmacsMode(boolean pEmacsMode)
Sets this logger to produce emacs (and other editor) friendly output.

Specified by:
setEmacsMode in interface org.apache.tools.ant.BuildLogger
Parameters:
pEmacsMode - true if output is to be unadorned so that emacs and other editors can parse files names, etc.

buildStarted

public final void buildStarted(org.apache.tools.ant.BuildEvent event)
Responds to a build being started by just remembering the current time.

Specified by:
buildStarted in interface org.apache.tools.ant.BuildListener
Parameters:
event - Ignored.

buildFinished

public final void buildFinished(org.apache.tools.ant.BuildEvent event)
Prints whether the build succeeded or failed, any errors the occured during the build, and how long the build took.

Specified by:
buildFinished in interface org.apache.tools.ant.BuildListener
Parameters:
event - An event with any relevant extra information. Must not be null.

targetStarted

public final void targetStarted(org.apache.tools.ant.BuildEvent event)
Logs a message to say that the target has started if this logger allows information-level messages.

Specified by:
targetStarted in interface org.apache.tools.ant.BuildListener
Parameters:
event - An event with any relevant extra information. Must not be null.

targetFinished

public final void targetFinished(org.apache.tools.ant.BuildEvent event)
No-op implementation.

Specified by:
targetFinished in interface org.apache.tools.ant.BuildListener
Parameters:
event - Ignored.

taskStarted

public final void taskStarted(org.apache.tools.ant.BuildEvent event)
No-op implementation.

Specified by:
taskStarted in interface org.apache.tools.ant.BuildListener
Parameters:
event - Ignored.

taskFinished

public final void taskFinished(org.apache.tools.ant.BuildEvent event)
No-op implementation.

Specified by:
taskFinished in interface org.apache.tools.ant.BuildListener
Parameters:
event - Ignored.

messageLogged

public final void messageLogged(org.apache.tools.ant.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:
messageLogged in interface org.apache.tools.ant.BuildListener
Parameters:
event - A BuildEvent containing message information. Must not be null.

formatTime

protected static java.lang.String formatTime(long millis)
Convenience method to format a specified length of time.

Parameters:
millis - Length of time to format, in milliseonds.
Returns:
the time as a formatted string.
See Also:
DateUtils.formatElapsedTime(long)

printMessage

protected final 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.)

log

protected final 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.

setMsgOutputLevel

protected final void setMsgOutputLevel(int pMsgOutputLevel)
Set the log level of the logging panel

Parameters:
pMsgOutputLevel - the level


Copyright © 2002-2004 devaki.org. All Rights Reserved.