How about my patch to DefaultLogger?
My patch (in Bugzilla) allows DefaultLogger to get subclassed so output can
pass-through to subclasses and be captured by it - so you can get the same
output captured by a subclass that gets output rather than hacking off the
output file. If my patch gets applied, I have a MailLogger ready and
waiting to submit that subclasses from it and sends e-mails of the build
results - which is better than the BuildListener in the FAQ because is more
transparent (the FAQ is fishy anyway because you need to specify a logfile
command-line switch to make it work and its not in the example shown - I
believe).
It would be very good to get a MailLogger into the core so that the FAQ can
finally be updated to just say:
ant -logger org.apache.tools.ant.MailLogger
:)
Erik
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 23, 2001 7:53 AM
Subject: cvs commit: jakarta-ant/src/main/org/apache/tools/ant
DefaultLogger.java
> 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:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>