@@ -65,6 +65,7 @@ public class DefaultLogger implements BuildLogger {
private static int LEFT_COLUMN_SIZE = 12;
private static int LEFT_COLUMN_SIZE = 12;
private PrintStream out;
private PrintStream out;
private PrintStream err;
private int msgOutputLevel;
private int msgOutputLevel;
private long startTime = System.currentTimeMillis();
private long startTime = System.currentTimeMillis();
@@ -94,6 +95,15 @@ public class DefaultLogger implements BuildLogger {
this.out = output;
this.out = output;
}
}
/**
* Set the output stream to which this logger is to send error messages.
*
* @param err the error stream for the logger.
*/
public void setErrorPrintStream(PrintStream err) {
this.err = err;
}
/**
/**
* Set this logger to produce emacs (and other editor) friendly output.
* Set this logger to produce emacs (and other editor) friendly output.
*
*
@@ -120,18 +130,18 @@ public class DefaultLogger implements BuildLogger {
out.println(lSep + "BUILD SUCCESSFUL");
out.println(lSep + "BUILD SUCCESSFUL");
}
}
else {
else {
out .println(lSep + "BUILD FAILED" + lSep);
err .println(lSep + "BUILD FAILED" + lSep);
if (error instanceof BuildException) {
if (error instanceof BuildException) {
out .println(error.toString());
err .println(error.toString());
Throwable nested = ((BuildException)error).getException();
Throwable nested = ((BuildException)error).getException();
if (nested != null) {
if (nested != null) {
nested.printStackTrace(out );
nested.printStackTrace(err );
}
}
}
}
else {
else {
error.printStackTrace(out );
error.printStackTrace(err );
}
}
}
}
@@ -152,6 +162,8 @@ public class DefaultLogger implements BuildLogger {
public void messageLogged(BuildEvent event) {
public void messageLogged(BuildEvent event) {
PrintStream logTo = event.getPriority() == Project.MSG_ERR ? err : out;
// Filter out messages based on priority
// Filter out messages based on priority
if (event.getPriority() <= msgOutputLevel) {
if (event.getPriority() <= msgOutputLevel) {
@@ -162,14 +174,14 @@ public class DefaultLogger implements BuildLogger {
if (!emacsMode) {
if (!emacsMode) {
String msg = "[" + name + "] ";
String msg = "[" + name + "] ";
for (int i = 0; i < (LEFT_COLUMN_SIZE - msg.length()); i++) {
for (int i = 0; i < (LEFT_COLUMN_SIZE - msg.length()); i++) {
out .print(" ");
logTo .print(" ");
}
}
out .print(msg);
logTo .print(msg);
}
}
}
}
// Print the message
// Print the message
out .println(event.getMessage());
logTo .println(event.getMessage());
}
}
}
}