Methods Summary |
---|
public void | buildFinished(BuildEvent event)Prints whether the build succeeded or failed,
any errors the occurred during the build, and
how long the build took.
Throwable error = event.getException();
StringBuffer message = new StringBuffer();
if (error == null) {
message.append(StringUtils.LINE_SEP);
message.append(getBuildSuccessfulMessage());
} else {
message.append(StringUtils.LINE_SEP);
message.append(getBuildFailedMessage());
message.append(StringUtils.LINE_SEP);
if (Project.MSG_VERBOSE <= msgOutputLevel
|| !(error instanceof BuildException)) {
message.append(StringUtils.getStackTrace(error));
} else {
message.append(error.toString()).append(lSep);
}
}
message.append(StringUtils.LINE_SEP);
message.append("Total time: ");
message.append(formatTime(System.currentTimeMillis() - startTime));
String msg = message.toString();
if (error == null) {
printMessage(msg, out, Project.MSG_VERBOSE);
} else {
printMessage(msg, err, Project.MSG_ERR);
}
log(msg);
|
public void | buildStarted(BuildEvent event)Responds to a build being started by just remembering the current time.
startTime = System.currentTimeMillis();
|
protected static java.lang.String | formatTime(long millis)Convenience method to format a specified length of time.
return DateUtils.formatElapsedTime(millis);
|
protected java.lang.String | getBuildFailedMessage()This is an override point: the message that indicates whether a build failed.
Subclasses can change/enhance the message.
return "BUILD FAILED";
|
protected java.lang.String | getBuildSuccessfulMessage()This is an override point: the message that indicates that a build succeeded.
Subclasses can change/enhance the message.
return "BUILD SUCCESSFUL";
|
protected void | log(java.lang.String message)Empty implementation which allows subclasses to receive the
same output that is generated here.
|
public 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.
int priority = event.getPriority();
// Filter out messages based on priority
if (priority <= msgOutputLevel) {
StringBuffer message = new StringBuffer();
if (event.getTask() != null && !emacsMode) {
// Print out the name of the task if we're in one
String name = event.getTask().getTaskName();
String label = "[" + name + "] ";
int size = LEFT_COLUMN_SIZE - label.length();
StringBuffer tmp = new StringBuffer();
for (int i = 0; i < size; i++) {
tmp.append(" ");
}
tmp.append(label);
label = tmp.toString();
try {
BufferedReader r =
new BufferedReader(
new StringReader(event.getMessage()));
String line = r.readLine();
boolean first = true;
do {
if (first) {
if (line == null) {
message.append(label);
break;
}
} else {
message.append(StringUtils.LINE_SEP);
}
first = false;
message.append(label).append(line);
line = r.readLine();
} while (line != null);
} catch (IOException e) {
// shouldn't be possible
message.append(label).append(event.getMessage());
}
} else {
message.append(event.getMessage());
}
Throwable ex = event.getException();
if (Project.MSG_DEBUG <= msgOutputLevel && ex != null) {
message.append(StringUtils.getStackTrace(ex));
}
String msg = message.toString();
if (priority != Project.MSG_ERR) {
printMessage(msg, out, priority);
} else {
printMessage(msg, err, priority);
}
log(msg);
}
|
protected void | printMessage(java.lang.String message, java.io.PrintStream stream, int priority)Prints a message to a PrintStream.
stream.println(message);
|
public void | setEmacsMode(boolean emacsMode)Sets this logger to produce emacs (and other editor) friendly output.
this.emacsMode = emacsMode;
|
public void | setErrorPrintStream(java.io.PrintStream err)Sets the output stream to which this logger is to send error messages.
this.err = new PrintStream(err, true);
|
public 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
{@link Project 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.
this.msgOutputLevel = level;
|
public void | setOutputPrintStream(java.io.PrintStream output)Sets the output stream to which this logger is to send its output.
this.out = new PrintStream(output, true);
|
public void | targetFinished(BuildEvent event)No-op implementation.
|
public void | targetStarted(BuildEvent event)Logs a message to say that the target has started if this
logger allows information-level messages.
if (Project.MSG_INFO <= msgOutputLevel
&& !event.getTarget().getName().equals("")) {
String msg = StringUtils.LINE_SEP
+ event.getTarget().getName() + ":";
printMessage(msg, out, event.getPriority());
log(msg);
}
|
public void | taskFinished(BuildEvent event)No-op implementation.
|
public void | taskStarted(BuildEvent event)No-op implementation.
|