Tailing a log file?

Evan Klitzke evan at yelp.com
Fri Jun 22 14:20:03 EDT 2007


Everyone,

I'm interested in writing a python program that reads from a log file
and then executes actions based on the lines. I effectively want to
write a loop that does something like this:

while True:
    log_line = log_file.readline()
    do_something(log_line)

Where the readline() method blocks until a new line appears in the
file, unlike the standard readline() method which returns an empty
string on EOF. Does anyone have any suggestions on how to do this?
Thanks in advance!

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list