Browse Source

simplify DefaultLogger

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

+ 13
- 14
src/main/org/apache/tools/ant/DefaultLogger.java View File

@@ -99,7 +99,7 @@ public class DefaultLogger implements BuildLogger {
* @param output the output stream for the logger.
*/
public void setOutputPrintStream(PrintStream output) {
this.out = output;
this.out = new PrintStream(output, true);
}

/**
@@ -108,7 +108,7 @@ public class DefaultLogger implements BuildLogger {
* @param err the error stream for the logger.
*/
public void setErrorPrintStream(PrintStream err) {
this.err = err;
this.err = new PrintStream(err, true);
}

/**
@@ -160,14 +160,18 @@ public class DefaultLogger implements BuildLogger {
+ formatTime(System.currentTimeMillis() - startTime));

String msg = message.toString();
printlnAndFlush(error == null ? out : err, msg);
if (error == null) {
out.println(msg);
} else {
err.println(msg);
}
log(msg);
}

public void targetStarted(BuildEvent event) {
if (Project.MSG_INFO <= msgOutputLevel) {
String msg = lSep + event.getTarget().getName() + ":";
printlnAndFlush(out, msg);
out.println(msg);
log(msg);
}
}
@@ -198,8 +202,11 @@ public class DefaultLogger implements BuildLogger {

message.append(event.getMessage());
String msg = message.toString();
printlnAndFlush(event.getPriority() != Project.MSG_ERR ? out : err,
msg);
if (event.getPriority() != Project.MSG_ERR) {
out.println(msg);
} else {
err.println(msg);
}
log(msg);
}
}
@@ -228,12 +235,4 @@ public class DefaultLogger implements BuildLogger {
*/
protected void log(String message) {}

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

}

Loading…
Cancel
Save