You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Paul Hammant <pa...@hammant.org> on 2006/08/10 02:14:08 UTC

Can DefaultLogger record the time on each target transition?

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


Re: Can DefaultLogger record the time on each target transition?

Posted by Alexey Solofnenko <tr...@gmail.com>.
Have you tried 2>&1 redirection?

- Alexey.

On 8/9/06, Paul Hammant <pa...@hammant.org> wrote:
>
>
> 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
>
>


-- 
Alexey N. Solofnenko trelony at gmail.com
home: http://trelony.cjb.net/
Pleasant Hill, CA (GMT-8 hours usually)