ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Hammant" <p...@hammant.org>
Subject Can DefaultLogger record the time on each target transition?
Date Thu, 10 Aug 2006 00:14:08 GMT

To code it in org.apache.tools.ant.DefaultLogger, add ...

  + " @ " + formatTime(System.currentTimeMillis() - startTime)

... to the msg being prepared.  Like so ....

    public void targetStarted(BuildEvent event) {
        if (Project.MSG_INFO <= msgOutputLevel
            && !event.getTarget().getName().equals("")) {
            String msg = StringUtils.LINE_SEP
                + event.getTarget().getName() + " @ " + formatTime(System.currentTimeMillis()
- startTime) + ":";
            printMessage(msg, out, event.getPriority());
            log(msg);
        }
    }

Works sweetly, but we don't want to maintain a forked Ant.

The other solution for us was to launch ant like so :

  ant -verbose -listener org.apache.tools.ant.listener.CommonsLoggingListener >&ant-output.txt

The redirection '>&' is out and err to the same log file. That only works on Unix.
On Windows the >ant-output.txt 2>ant-output.txt causes teh process handelr to barf suggesting
the file is already in use.

All we wanted was to work out how long each target was taking, without switching to an XML
logging format..

- Paul


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


Mime
View raw message