Appending a log file and see progress as program executes
Diez B. Roggisch
deets at nospam.web.de
Wed May 30 14:32:00 EDT 2007
Karim Ali schrieb:
> Hi,
>
> I am writing a program that will take several days to execute :) and
> would like to append to a log file but be able to open that file at any
> time and see the errors that have occured.
>
> So this is what I am doing:
>
> ----------------------------------------------
> flog = open('out.log', 'a')
> ....
> when needed:
> sys.stdout=flog
> print "error message"
> ------------------------------------------------
>
> This will print directly to log. I use sys.stdout so i can quickly (in
> code) change back and forth between errors displayed on screen and
> errors logged..
>
> This works great. The only problem is that I cant see anything in the
> log file when I try to open it say with notepad while the program is
> running...and this is not good at all!
>
> Any suggestions are appreciated.
install cygwin bash, and use
tail out.log
Diez
More information about the Python-list
mailing list