Reads log file lines that have not been read.
A python “port” of logcheck’s logtail2.
Pygtail reads log file lines that have not been read. It will even handle log files that have been rotated.
From the command line:
Usage: pygtail.py [options] logfile Print log file lines that have not been read. Options: -h, --help show this help message and exit -o OFFSET_FILE, --offset-file=OFFSET_FILE File to which offset data is written (default: <logfile>.offset). -p, --paranoid Update the offset file every time we read a line (as opposed to only when we reach the end of the file). -n N, --every-n=N Update the offset file every N'th time we read a line (as opposed to only when we reach the end of the file). --no-copytruncate Don't support copytruncate-style log rotation. Instead, if the log file shrinks, print a warning. --read-from-end Read log file from the end if offset file is missing. Useful for large files. --log-pattern Custom log rotation glob pattern. Use %s to represent the original filename. You may use this multiple times to provide multiple patterns. --version Print version and exit.
In your code:
from pygtail import Pygtail for line in Pygtail("some.log"): sys.stdout.write(line)
Pull requests are very much welcome, but I will not merge your changes if you don’t include a test. Run tests with python setup.py test.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|pygtail-0.10.0-py2.7.egg (10.7 kB) Copy SHA256 hash SHA256||Egg||2.7|
|pygtail-0.10.0-py3-none-any.whl (13.4 kB) Copy SHA256 hash SHA256||Wheel||py3|
|pygtail-0.10.0.tar.gz (5.7 kB) Copy SHA256 hash SHA256||Source||None|