ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: How to echo date-time to log file?
Date Tue, 14 Sep 2004 14:56:02 GMT
On Tue, 14 Sep 2004, Vadim Kazakov <VadimK@quadrus.com> wrote:

> You could use the new macrodef task to create a macro instead of
> using antcall

Yes, but keep in mind that you'll have to use a different property
name in each invocation that way since the first invocation will set
the property "logtime" and subsequent invocations won't override it.

<antcall> gets around this by using a separate property context with
the new subbuild.

<macrodef name="logWithTimestamp">
  <attribute name=logFile"/>
  <attribute name=message"/>
  <sequential>
    <tstamp>
      <format property="logtime.@{logFile}.@{message}" 
              pattern="yyyy.MM.dd ':' HH:mm:ss z"/>
    </tstamp>
    <echo file="${logFile}" append="true">${logtime.@{logFile}.@{message}} :: ${message}</echo>
  </sequential>
</macrodef>

will work if you never try to log the same message to the same file
twice inside the same build.  Otherwise you'll have to come up with a
smarter property name generation algorithm.

Stefan

-- 
http://stefanbodewig.blogger.de/

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


Mime
View raw message