bgreenlee / pygtail

Pygtail reads log file lines that have not been read. It will even handle log files that have been rotated. Based on logcheck's logtail2 (http://logcheck.org)
GNU General Public License v2.0
251 stars 79 forks source link

if we fail to find the rotated file, still set offset back to 0 #21

Closed mcodd closed 2 years ago

mcodd commented 9 years ago

We ran across an issue in the case where a logfile rotates, but Pygtail cannot find it. At that point it never starts parsing the new file - after each iteration of calling Pygtail in our script, it would parse 0 lines and update the offset file with the new logfile's inode, but the old (rotated) file's offset, and of course the new logfile's length was consistently less than the rotated one since it had been around for a lot less time.

The fix here works for us, but a better one might distinguish between the two cases where self._rotated_logfile is None (both in the normal case where nothing rotated, and the exception case where the log rotated, but _determine_rotated_logfile came up empty).