ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Doug" <Doug.Dani...@gdc4s.com>
Subject RE: How to echo date-time to log file?
Date Tue, 14 Sep 2004 15:32:10 GMT
It's looking like defining timestamp as a target, and using <antcall..> to get local
timestamp properties seems to be the easiest most straight forward approach. Because using
<antcall...> with parameters is basically as simple as using the defined macrodef.

You could put the timestamp target into a commontargets.xml and use <import file="commontargets.xml"/>
in your various build.xml's so you can re-use this functionality.

-----Original Message-----
From: Vadim Kazakov [mailto:VadimK@quadrus.com]
Sent: Tuesday, September 14, 2004 11:03 AM
To: Ant Users List
Subject: RE: How to echo date-time to log file?


""

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



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


Mime
View raw message