pygtail
=======
A python "port" of `logcheck's logtail2 <http://logcheck.org>`__.
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:
.. code:: python
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:
.. code:: python
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
------------
|Build Status|
.. |Build Status| image:: https://secure.travis-ci.org/bgreenlee/pygtail.png
:target: http://travis-ci.org/bgreenlee/pygtail
Raw data
{
"_id": null,
"home_page": "http://github.com/bgreenlee/pygtail",
"name": "pygtail",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "logging,tail,logtail2",
"author": "Brad Greenlee",
"author_email": "brad@footle.org",
"download_url": "https://files.pythonhosted.org/packages/b0/89/437120e303d5d2c81107ed3415d5f3c9975f7dfdeef9e4440cef364e3bf9/pygtail-0.14.0.tar.gz",
"platform": null,
"description": "pygtail\n=======\n\nA python \"port\" of `logcheck's logtail2 <http://logcheck.org>`__.\n\nPygtail reads log file lines that have not been read. It will even\nhandle log files that have been rotated.\n\nUsage\n-----\n\nFrom the command line:\n\n::\n\n Usage: pygtail.py [options] logfile\n\n Print log file lines that have not been read.\n\n Options:\n -h, --help show this help message and exit\n -o OFFSET_FILE, --offset-file=OFFSET_FILE\n File to which offset data is written (default:\n <logfile>.offset).\n -p, --paranoid Update the offset file every time we read a line\n (as opposed to only when we reach the end of the\n file).\n -n N, --every-n=N Update the offset file every N'th time we read a\n line (as opposed to only when we reach the end of\n the file).\n --no-copytruncate Don't support copytruncate-style log rotation.\n Instead, if the log file shrinks, print a warning.\n --read-from-end Read log file from the end if offset file is\n missing. Useful for large files.\n --log-pattern Custom log rotation glob pattern. Use %s to\n represent the original filename. You may use this\n multiple times to provide multiple patterns.\n --full_lines Only log when line ends in a newline `\\n`\n (default: False)\n --encoding ENCODING Encoding to use for reading files (default: system\n encoding)\n --version Print version and exit.\n\nIn your code:\n\n.. code:: python\n\n from pygtail import Pygtail\n\n for line in Pygtail(\"some.log\"):\n sys.stdout.write(line)\n\n\nAn example showing iterating over lines with offsets and manual control over offset updates:\n\n.. code:: python\n\n import pygtail\n\n tail = pygtail.Pygtail(logfile, save_on_end=False, copytruncate=False)\n\n for line, offset in tail.with_offsets():\n # Do someting\n\n # figure out right offset to save\n tail.write_offset_to_file(right_offset)\n\n\nContributing\n------------\n\nPull 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`.\n\nBuild status\n------------\n\n|Build Status|\n\n.. |Build Status| image:: https://secure.travis-ci.org/bgreenlee/pygtail.png\n :target: http://travis-ci.org/bgreenlee/pygtail\n",
"bugtrack_url": null,
"license": "GPL v2",
"summary": "Reads log file lines that have not been read.",
"version": "0.14.0",
"project_urls": {
"Homepage": "http://github.com/bgreenlee/pygtail"
},
"split_keywords": [
"logging",
"tail",
"logtail2"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43775558c3904229d2e320722ec58d38b82f9ff3063b7eeda49a8821b5595de1",
"md5": "59032a994e753b55cdb9f645d9b49054",
"sha256": "3d8e847d4d5c56e3cece1f65577562e63f8b75af7b93bf21b71c3213d369c2a9"
},
"downloads": -1,
"filename": "pygtail-0.14.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "59032a994e753b55cdb9f645d9b49054",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 14319,
"upload_time": "2022-11-06T14:54:26",
"upload_time_iso_8601": "2022-11-06T14:54:26.714377Z",
"url": "https://files.pythonhosted.org/packages/43/77/5558c3904229d2e320722ec58d38b82f9ff3063b7eeda49a8821b5595de1/pygtail-0.14.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b089437120e303d5d2c81107ed3415d5f3c9975f7dfdeef9e4440cef364e3bf9",
"md5": "396e8c316430063f841edde66ca9e1d3",
"sha256": "55616d31a081eaaeb069d0946f2bc7e530ebf505d4c3c050f8e941786a3449d3"
},
"downloads": -1,
"filename": "pygtail-0.14.0.tar.gz",
"has_sig": false,
"md5_digest": "396e8c316430063f841edde66ca9e1d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13509,
"upload_time": "2022-11-06T14:54:28",
"upload_time_iso_8601": "2022-11-06T14:54:28.816648Z",
"url": "https://files.pythonhosted.org/packages/b0/89/437120e303d5d2c81107ed3415d5f3c9975f7dfdeef9e4440cef364e3bf9/pygtail-0.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-11-06 14:54:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bgreenlee",
"github_project": "pygtail",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pygtail"
}