pygtail
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.
Usage
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.
--full_lines Only log when line ends in a newline `\n`
(default: False)
--encoding ENCODING Encoding to use for reading files (default: system
encoding)
--version Print version and exit.
In your code:
from pygtail import Pygtail
for line in Pygtail("some.log"):
sys.stdout.write(line)
An example showing iterating over lines with offsets and manual control over offset updates:
import pygtail
tail = pygtail.Pygtail(logfile, save_on_end=False, copytruncate=False)
for line, offset in tail.with_offsets():
# Do someting
# figure out right offset to save
tail.write_offset_to_file(right_offset)
Contributing
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.
Build status
Metadata
Release files for pygtail 0.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygtail-0.14.0.tar.gz | 13.5 kB | Without provenance | Details for pygtail-0.14.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygtail-0.14.0-py3-none-any.whl | Python 3 | none | any | Details for pygtail-0.14.0-py3-none-any.whl |
Total release size: 27.8 kB
Release files / pygtail-0.14.0.tar.gz
| Download URL | pygtail-0.14.0.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55616d31a081eaaeb069d0946f2bc7e530ebf505d4c3c050f8e941786a3449d3
|
|
BLAKE2b-256 checksum How to use checksums |
b089437120e303d5d2c81107ed3415d5f3c9975f7dfdeef9e4440cef364e3bf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.15
|
Release files / pygtail-0.14.0-py3-none-any.whl
| Download URL | pygtail-0.14.0-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d8e847d4d5c56e3cece1f65577562e63f8b75af7b93bf21b71c3213d369c2a9
|
|
BLAKE2b-256 checksum How to use checksums |
43775558c3904229d2e320722ec58d38b82f9ff3063b7eeda49a8821b5595de1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.15
|
Security for pygtail 0.14.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.