ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Kazakov" <Vad...@quadrus.com>
Subject RE: How to echo date-time to log file?
Date Tue, 14 Sep 2004 15:02:51 GMT
Ah true, I forgot about that part.

-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org] 
Sent: September 14, 2004 8:56 AM
To: user@ant.apache.org
Subject: Re: How to echo date-time to log file?

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


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


Mime
View raw message