Browse Source

flush logfile while logging - otherwise tail -f get's boring.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269998 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
0551fff524
1 changed files with 15 additions and 6 deletions
  1. +15
    -6
      src/main/org/apache/tools/ant/DefaultLogger.java

+ 15
- 6
src/main/org/apache/tools/ant/DefaultLogger.java View File

@@ -133,18 +133,19 @@ public class DefaultLogger implements BuildLogger {
Throwable error = event.getException();

if (error == null) {
out.println(lSep + "BUILD SUCCESSFUL");
printlnAndFlush(out, lSep + "BUILD SUCCESSFUL");
}
else {
err.println(lSep + "BUILD FAILED" + lSep);
printlnAndFlush(err, lSep + "BUILD FAILED" + lSep);

if (Project.MSG_VERBOSE <= msgOutputLevel ||
!(error instanceof BuildException)) {
error.printStackTrace(err);
err.flush();
}
else {
if (error instanceof BuildException) {
err.println(error.toString());
printlnAndFlush(err, error.toString());
}
else {
err.println(error.getMessage());
@@ -152,12 +153,12 @@ public class DefaultLogger implements BuildLogger {
}
}

out.println(lSep + "Total time: " + formatTime(System.currentTimeMillis() - startTime));
printlnAndFlush(out, lSep + "Total time: " + formatTime(System.currentTimeMillis() - startTime));
}

public void targetStarted(BuildEvent event) {
if (Project.MSG_INFO <= msgOutputLevel) {
out.println(lSep + event.getTarget().getName() + ":");
printlnAndFlush(out, lSep + event.getTarget().getName() + ":");
}
}

@@ -188,7 +189,7 @@ public class DefaultLogger implements BuildLogger {
}

// Print the message
logTo.println(event.getMessage());
printlnAndFlush(logTo, event.getMessage());
}
}

@@ -210,4 +211,12 @@ public class DefaultLogger implements BuildLogger {

}

/**
* Print a line to the given stream and flush the stream right after that.
*/
private void printlnAndFlush(PrintStream p, String line) {
p.println(line);
p.flush();
}

}

Loading…
Cancel
Save