.. image:: http://www.repostatus.org/badges/latest/active.svg
:target: http://www.repostatus.org/#active
:alt: Project Status: Active — The project has reached a stable, usable
state and is being actively developed.
.. image:: https://travis-ci.com/jwodder/apachelogs.svg?branch=master
:target: https://travis-ci.com/jwodder/apachelogs
.. image:: https://codecov.io/gh/jwodder/apachelogs/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jwodder/apachelogs
.. image:: https://img.shields.io/pypi/pyversions/apachelogs.svg
:target: https://pypi.org/project/apachelogs/
.. image:: https://img.shields.io/github/license/jwodder/apachelogs.svg
:target: https://opensource.org/licenses/MIT
:alt: MIT License
.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg
:target: https://saythanks.io/to/jwodder
`GitHub <https://github.com/jwodder/apachelogs>`_
| `PyPI <https://pypi.org/project/apachelogs/>`_
| `Documentation <https://apachelogs.readthedocs.io>`_
| `Issues <https://github.com/jwodder/apachelogs/issues>`_
| `Changelog <https://github.com/jwodder/apachelogs/blob/master/CHANGELOG.md>`_
``apachelogs`` parses Apache access log files. Pass it a `log format string
<http://httpd.apache.org/docs/current/mod/mod_log_config.html>`_ and get back a
parser for logfile entries in that format. ``apachelogs`` even takes care of
decoding escape sequences and converting things like timestamps, integers, and
bare hyphens to ``datetime`` values, ``int``\s, and ``None``\s.
Installation
============
``apachelogs`` requires Python 3.5 or higher. Just use `pip
<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install
``apachelogs`` and its dependencies::
python3 -m pip install apachelogs
Examples
========
Parse a single log entry::
>>> from apachelogs import LogParser
>>> parser = LogParser("%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"")
>>> # The above log format is also available as the constant `apachelogs.COMBINED`.
>>> entry = parser.parse('209.126.136.4 - - [01/Nov/2017:07:28:29 +0000] "GET / HTTP/1.1" 301 521 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"\n')
>>> entry.remote_host
'209.126.136.4'
>>> entry.request_time
datetime.datetime(2017, 11, 1, 7, 28, 29, tzinfo=datetime.timezone.utc)
>>> entry.request_line
'GET / HTTP/1.1'
>>> entry.final_status
301
>>> entry.bytes_sent
521
>>> entry.headers_in["Referer"] is None
True
>>> entry.headers_in["User-Agent"]
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
>>> # Log entry components can also be looked up by directive:
>>> entry.directives["%r"]
'GET / HTTP/1.1'
>>> entry.directives["%>s"]
301
>>> entry.directives["%t"]
datetime.datetime(2017, 11, 1, 7, 28, 29, tzinfo=datetime.timezone.utc)
Parse a file full of log entries::
>>> with open('/var/log/apache2/access.log') as fp: # doctest: +SKIP
... for entry in parser.parse_lines(fp):
... print(str(entry.request_time), entry.request_line)
...
2019-01-01 12:34:56-05:00 GET / HTTP/1.1
2019-01-01 12:34:57-05:00 GET /favicon.ico HTTP/1.1
2019-01-01 12:34:57-05:00 GET /styles.css HTTP/1.1
# etc.
Raw data
{
"_id": null,
"home_page": "https://github.com/jwodder/apachelogs",
"name": "apachelogs",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.5",
"maintainer_email": "",
"keywords": "Apache,access logs,httpd,logfiles",
"author": "John Thorvald Wodder II",
"author_email": "apachelogs@varonathe.org",
"download_url": "https://files.pythonhosted.org/packages/5a/33/433b35030271953cf57c1257212de71dfe63e1bb989018796c914e8f4be3/apachelogs-0.6.0.tar.gz",
"platform": "",
"description": ".. image:: http://www.repostatus.org/badges/latest/active.svg\n :target: http://www.repostatus.org/#active\n :alt: Project Status: Active \u2014 The project has reached a stable, usable\n state and is being actively developed.\n\n.. image:: https://travis-ci.com/jwodder/apachelogs.svg?branch=master\n :target: https://travis-ci.com/jwodder/apachelogs\n\n.. image:: https://codecov.io/gh/jwodder/apachelogs/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/jwodder/apachelogs\n\n.. image:: https://img.shields.io/pypi/pyversions/apachelogs.svg\n :target: https://pypi.org/project/apachelogs/\n\n.. image:: https://img.shields.io/github/license/jwodder/apachelogs.svg\n :target: https://opensource.org/licenses/MIT\n :alt: MIT License\n\n.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\n :target: https://saythanks.io/to/jwodder\n\n`GitHub <https://github.com/jwodder/apachelogs>`_\n| `PyPI <https://pypi.org/project/apachelogs/>`_\n| `Documentation <https://apachelogs.readthedocs.io>`_\n| `Issues <https://github.com/jwodder/apachelogs/issues>`_\n| `Changelog <https://github.com/jwodder/apachelogs/blob/master/CHANGELOG.md>`_\n\n``apachelogs`` parses Apache access log files. Pass it a `log format string\n<http://httpd.apache.org/docs/current/mod/mod_log_config.html>`_ and get back a\nparser for logfile entries in that format. ``apachelogs`` even takes care of\ndecoding escape sequences and converting things like timestamps, integers, and\nbare hyphens to ``datetime`` values, ``int``\\s, and ``None``\\s.\n\n\nInstallation\n============\n``apachelogs`` requires Python 3.5 or higher. Just use `pip\n<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install\n``apachelogs`` and its dependencies::\n\n python3 -m pip install apachelogs\n\n\nExamples\n========\n\nParse a single log entry::\n\n >>> from apachelogs import LogParser\n >>> parser = LogParser(\"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\"\")\n >>> # The above log format is also available as the constant `apachelogs.COMBINED`.\n >>> entry = parser.parse('209.126.136.4 - - [01/Nov/2017:07:28:29 +0000] \"GET / HTTP/1.1\" 301 521 \"-\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36\"\\n')\n >>> entry.remote_host\n '209.126.136.4'\n >>> entry.request_time\n datetime.datetime(2017, 11, 1, 7, 28, 29, tzinfo=datetime.timezone.utc)\n >>> entry.request_line\n 'GET / HTTP/1.1'\n >>> entry.final_status\n 301\n >>> entry.bytes_sent\n 521\n >>> entry.headers_in[\"Referer\"] is None\n True\n >>> entry.headers_in[\"User-Agent\"]\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'\n >>> # Log entry components can also be looked up by directive:\n >>> entry.directives[\"%r\"]\n 'GET / HTTP/1.1'\n >>> entry.directives[\"%>s\"]\n 301\n >>> entry.directives[\"%t\"]\n datetime.datetime(2017, 11, 1, 7, 28, 29, tzinfo=datetime.timezone.utc)\n\nParse a file full of log entries::\n\n >>> with open('/var/log/apache2/access.log') as fp: # doctest: +SKIP\n ... for entry in parser.parse_lines(fp):\n ... print(str(entry.request_time), entry.request_line)\n ...\n 2019-01-01 12:34:56-05:00 GET / HTTP/1.1\n 2019-01-01 12:34:57-05:00 GET /favicon.ico HTTP/1.1\n 2019-01-01 12:34:57-05:00 GET /styles.css HTTP/1.1\n # etc.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse Apache access logs",
"version": "0.6.0",
"project_urls": {
"Bug Tracker": "https://github.com/jwodder/apachelogs/issues",
"Documentation": "https://apachelogs.readthedocs.io",
"Homepage": "https://github.com/jwodder/apachelogs",
"Say Thanks!": "https://saythanks.io/to/jwodder",
"Source Code": "https://github.com/jwodder/apachelogs"
},
"split_keywords": [
"apache",
"access logs",
"httpd",
"logfiles"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ec3816dfd236b34770161fbbd33081a50b703c66929dce4e3ca8f9d309642c43",
"md5": "a8528c0f9194bc2504f3310691b9bbbd",
"sha256": "dd8b6e4ee722f899bc558044663821dd47651fed436204a2e23bb5e8b28820a1"
},
"downloads": -1,
"filename": "apachelogs-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a8528c0f9194bc2504f3310691b9bbbd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.5",
"size": 18270,
"upload_time": "2020-10-13T22:24:39",
"upload_time_iso_8601": "2020-10-13T22:24:39.746857Z",
"url": "https://files.pythonhosted.org/packages/ec/38/16dfd236b34770161fbbd33081a50b703c66929dce4e3ca8f9d309642c43/apachelogs-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5a33433b35030271953cf57c1257212de71dfe63e1bb989018796c914e8f4be3",
"md5": "26619e62ab6bc0ebbe1034a818abe601",
"sha256": "1708c243bb555e28a5f46109736c191c1778a6a787b2e3bcd302fd9093bc783f"
},
"downloads": -1,
"filename": "apachelogs-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "26619e62ab6bc0ebbe1034a818abe601",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.5",
"size": 31372,
"upload_time": "2020-10-13T22:24:40",
"upload_time_iso_8601": "2020-10-13T22:24:40.548696Z",
"url": "https://files.pythonhosted.org/packages/5a/33/433b35030271953cf57c1257212de71dfe63e1bb989018796c914e8f4be3/apachelogs-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-10-13 22:24:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jwodder",
"github_project": "apachelogs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "apachelogs"
}