In this link, in the accepted answer, the Unix based solution is given. I want to do the same in windows. Since, i-node doesn't work with windows and python 2.7 stack I can't find any nice way to read a log file. My current way is something like this:
import time
cur = 0
while True:
try:
with open('myfile') as f:
f.seek(0,2)
if f.tell() < cur:
f.seek(0,0)
else:
f.seek(cur,0)
for line in f:
print line.strip()
cur = f.tell()
except IOError, e:
pass
time.sleep(1)
The problem with this is the last lines will be missed if the lines are appended while time-sleeping, and rotation occurs before wake up. It is important for me to read all the lines. Is there any way I can do this in windows?