Log file name should have date and time stamp

1,004 views
Skip to first unread message

vasu

unread,
Sep 5, 2008, 3:31:36 AM9/5/08
to Watir General
Hi,

I want to create a log file name with date and time stamp. Please let
me know how can i do it. Output files format is TXT and XLS

Thanks,
Vasu

sandeep p

unread,
Sep 5, 2008, 5:32:50 AM9/5/08
to Watir General
See if this works for you

fileName=Time.now.to_s.gsub(/[ :]/,'_')
fileName="C:\\temp\\"+fileName+".txt"

logCommentFile = File.new(fileName, "a")

Ramana Reddy

unread,
Sep 5, 2008, 6:09:14 AM9/5/08
to watir-...@googlegroups.com
Try below one

time = Time.now.strftime("%m%d%Y%H%M%S")
fileName="C:\\temp\\"+time+".txt"

juuser

unread,
Sep 8, 2008, 2:16:21 AM9/8/08
to Watir General
I would recommend Ruby's bundled class Logger for logging.

Just see http://www.ruby-doc.org/core/classes/Logger.html

It has also good examples. This will take care of your logging (for
example, use "daily" as a parameter and so on).

On Sep 5, 1:09 pm, "Ramana Reddy" <ramana....@gmail.com> wrote:
> Try below one
>
> time = Time.now.strftime("%m%d%Y%H%M%S")
> fileName="C:\\temp\\"+time+".txt"
>
>
>
> > logCommentFile = File.new(fileName, "a")

marekj

unread,
Sep 8, 2008, 11:19:19 AM9/8/08
to watir-...@googlegroups.com

On Mon, Sep 8, 2008 at 1:16 AM, juuser <Jar...@gmail.com> wrote:

I would recommend Ruby's bundled class Logger for logging.

Just see http://www.ruby-doc.org/core/classes/Logger.html

It has also good examples. This will take care of your logging (for
example, use "daily" as a parameter and so on).



http://gist.github.com/3466


--
marekj

www.testr.us | semantic test objects modeling in watir
Reply all
Reply to author
Forward
0 new messages