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 14:44:34 GMT
You could use the new macrodef task to create a macro instead of using
antcall

-----Original Message-----
From: Daniels, Doug [mailto:Doug.Daniels@gdc4s.com] 
Sent: September 14, 2004 8:24 AM
To: Ant Users List
Subject: RE: How to echo date-time to log file?

Here's an idea:

You create a target in your build file called TimeStamp. Then to use
this task you make <antcall..>'s to it and pass in the LogFile, and the
Message properties to it. This allows you to have a generic logging
timestamp task that can log messages to files with a timestamp.

Maybe someone has an idea of extending this, using macrodef, or
whatever, I haven't really looked at that part of ant yet. Here is an
example build file to give you an idea of how it can be used:

<project default="buildPartX">


	<target name="timestamp">


		<tstamp>
		
			<format property="logtime" pattern="yyyy.MM.dd
':' HH:mm:ss z" />
			
		</tstamp>

		<echo file="${LogFile}" message="${logtime} ::
${Message}" append="true" />

	</target>


	<target name="buildPartX">

		<!-- Define various log files to log to -->
		<property name="BuildLog" value="build.log"/>
		<property name="OtherLog" value="other.log"/>

		<!--Do some work then print message with time -->

		<antcall target="timestamp">
			<param name="LogFile" value="${BuildLog}"/>
			<param name="Message" value="I just finished
this part of the build" />
		</antcall>


		<!-- Do some more work and print another message to a
different log -->
		<sleep seconds="2"/>

		<antcall target="timestamp">
			<param name="LogFile" value="${OtherLog}"/>
			<param name="Message" value="I just finished
another part of the build" />
		</antcall>

	</target>

</project>



-----Original Message-----
From: Patrick Surry [mailto:Patrick.Surry@quadstone.com]
Sent: Tuesday, September 14, 2004 9:10 AM
To: Ant Users List
Subject: How to echo date-time to log file?


""

This seems like a stupid question (and probably is!) but I can't seem to
find 
what I'm looking for anywhere obvious.  I have a build that takes a long
time, 
and would like to be able to record the current date/time at various
points 
throughout the build.  Just like you get when you run in 'verbose' mode
but 
without all the extra verbosity.  Ideally I'd want something like a
'timestamp' 
attribute in the echo task, so I could do things like:

<echo timestamp="true" message="Starting job..."/>
...
<echo timestamp="true" message="Finished job."/>

Are there any obvious solutions to this - running an exec with a 'time'
command 
seems like a hack, <tstamp/> doesn't really do what I want; the
ant-contrib 
<stopwatch/> doesn't give absolute times, just differences; the
<record/> task 
probably could change log verbosity to force ant-generated timestamps at

different points but again seems roundabout/overkill.

Patrick

---------------------------------------------------------------------
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