ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant DefaultLogger.java
Date Fri, 23 Nov 2001 12:53:43 GMT
bodewig     01/11/23 04:53:43

  Modified:    src/main/org/apache/tools/ant DefaultLogger.java
  Log:
  flush logfile while logging - otherwise tail -f get's boring.
  
  Revision  Changes    Path
  1.20      +15 -6     jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java
  
  Index: DefaultLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DefaultLogger.java	2001/10/28 21:25:26	1.19
  +++ DefaultLogger.java	2001/11/23 12:53:43	1.20
  @@ -133,18 +133,19 @@
           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 @@
               }
           }
   
  -        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 @@
               }
   
               // Print the message
  -            logTo.println(event.getMessage());
  +            printlnAndFlush(logTo, event.getMessage());
           }
       }
   
  @@ -208,6 +209,14 @@
                   + (seconds%60 == 1 ? "" : "s");
           }
   
  +    }
  +
  +    /**
  +     * 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();
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message