{ "info": { "author": "Jonny Fuller", "author_email": "mr.waffles@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Site Management", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: System :: Logging", "Topic :: System :: Monitoring" ], "description": "# WSGI Listener\n\n## Request/Response Inspection for WSGI Web Applications\nWSGI listener middleware for WSGI Web Applications inspired by the\noriginal wsgi-request-logger by Philipp Klaus and L. C. Rees.\n\nProvides hooks during the request and response cycle by adding an extra level of indirection.\n\nInstead of directly logging the response, this middleware provides an\ninterface to easily inspect the request and response. The default\nbehavior logs the response similarly to the original project. However, now\nadditional listeners can be added to both the request and response cycle.\nThe request and response body content is part of the interface.\n\nProject Homepage: https://github.com/JonnyWaffles/wsgi-listener\nOriginal project's Homepage: https://github.com/pklaus/wsgi-request-logger\n\nEasily add loggers, emailers, event systems, etc, with the `request_listeners` and `response_listener` hooks.\n\n#### Installation\ntodo: Ship to pypi\nSimply install this Python module via\n\n pip install wsgi-listener\n\n#### Usage\nTo add this middleware to your WSGI `application` with the default response logger named `wsgilistener` in Apache format.\n```python\nfrom wsgi_listener import WSGIListenerMiddleware\n\n \ndef application(environ, start_response):\n response_body = 'The request method was %s' % environ['REQUEST_METHOD']\n response_body = response_body.encode('utf-8')\n response_headers = [('Content-Type', 'text/plain'),\n ('Content-Length', str(len(response_body)))]\n start_response('200 OK', response_headers)\n return [response_body]\n\n\nloggingapp = WSGIListenerMiddleware(application)\n\nif __name__ == '__main__':\n from wsgiref.simple_server import make_server\n http = make_server('', 8080, loggingapp)\n http.serve_forever()\n```\n#### Custom handlers\nThe interface for the Request listeners is:\n```python\nfrom abc import ABC, abstractmethod\n\nclass AbstractBaseRequestListener(ABC):\n @abstractmethod\n def handle(self, environ: dict, request_body: bytes, **kwargs) -> None:\n \"\"\"Defines the interface for Request listeners.\n\n Args:\n environ: The WSGI envion dictionary\n request_body: The bytes content of the request, if any\n **kwargs: Optional hook for additional data\n \"\"\"\n```\nand the interface for Response listeners is:\n```python\nfrom abc import ABC, abstractmethod\n\nclass AbstractBaseResponseListener(ABC):\n @abstractmethod\n def handle(self, status_code: int, environ: dict, content_length: int, response_body: bytes,\n processing_time: float, **kwargs) -> None:\n \"\"\"Defines the interface for Response listeners.\n\n Args:\n status_code: HTTP status code as integer\n environ: WSGI environ dictionary\n content_length: Number of bytes returned as int\n response_body: The response content, if any\n processing_time: The time in miliseconds to process the request\n **kwargs: Extensible hook\n \"\"\"\n```\nSimply instantiate your hooks and add them during init or with the `add_listener` methods.\n\n#### The Authors\n\nThis WSGI middleware was originally developed under the name [wsgilog](https://pypi.python.org/pypi/wsgilog/) by **L. C. Rees**.\nIt was forked by **Philipp Klaus** in 2013 to build a WSGI middleware for request logging rather than exception handling and logging,\nand then forked again by **Jonny Fuller** in 2019 to add the additional layer of indirection. \n\n\n#### License\n\nThis software, *wsgi-listener*, is published under a *3-clause BSD license*.\n\n#### Developers' Resources\n\n* The [WSGI](http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface) - Web Server Gateway Interface - is defined in [PEP 333](http://www.python.org/dev/peps/pep-0333/) with an update for Python 3 in [PEP 3333](http://www.python.org/dev/peps/pep-3333/).\n\n#### General References\n\n* PyPI's [listing of wsgi-request-logger](https://pypi.python.org/pypi/wsgi-request-logger)\n* This fork source code is hosted at Github (todo determine url)\n* The original source code for this Python module is [hosted on Github](https://github.com/pklaus/wsgi-request-logger).\n* A blog post with more background information and usage examples:\n [wsgi-request-logger \u2013 Logging HTTP Requests With Any WSGI Web Application like Flask, Bottle or Django](https://blog.philippklaus.de/2013/06/wsgi-request-logger-logging-http-requests-with-any-wsgi-web-application-like-flask-bottle-or-django/)\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JonnyWaffles/wsgi-listener", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "wsgi_listener", "package_url": "https://pypi.org/project/wsgi_listener/", "platform": "", "project_url": "https://pypi.org/project/wsgi_listener/", "project_urls": { "Homepage": "https://github.com/JonnyWaffles/wsgi-listener" }, "release_url": "https://pypi.org/project/wsgi_listener/0.1/", "requires_dist": [ "sphinx; extra == \"doc\"", "pytest; extra == \"test\"" ], "requires_python": ">=3.5", "summary": "WSGI listener middleware for WSGI Web Applications inspired by the", "version": "0.1" }, "last_serial": 6004448, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "95f8f6c8433b4722cb6e877251a7010a", "sha256": "c531168d67176a1594987961c1f00461c39f8960704bf829b843b1aaf024dd2f" }, "downloads": -1, "filename": "wsgi_listener-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "95f8f6c8433b4722cb6e877251a7010a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 18965, "upload_time": "2019-10-20T19:37:50", "url": "https://files.pythonhosted.org/packages/a3/c7/7930b73acb524b14505c9d53ec88ac12d5a14e5bdf0695c550a59a95db2b/wsgi_listener-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8478e68648c1d34e368e6624fe5c735e", "sha256": "05432bf8947e2dcfccfac259bcb5d9010688c0388648a0e791c4429f4f855211" }, "downloads": -1, "filename": "wsgi_listener-0.1.tar.gz", "has_sig": false, "md5_digest": "8478e68648c1d34e368e6624fe5c735e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8800, "upload_time": "2019-10-20T19:38:08", "url": "https://files.pythonhosted.org/packages/95/64/339a2383a35aa9cf95b7e99abc804bd7c643905ae6d72c3b6373175172b3/wsgi_listener-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95f8f6c8433b4722cb6e877251a7010a", "sha256": "c531168d67176a1594987961c1f00461c39f8960704bf829b843b1aaf024dd2f" }, "downloads": -1, "filename": "wsgi_listener-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "95f8f6c8433b4722cb6e877251a7010a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 18965, "upload_time": "2019-10-20T19:37:50", "url": "https://files.pythonhosted.org/packages/a3/c7/7930b73acb524b14505c9d53ec88ac12d5a14e5bdf0695c550a59a95db2b/wsgi_listener-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8478e68648c1d34e368e6624fe5c735e", "sha256": "05432bf8947e2dcfccfac259bcb5d9010688c0388648a0e791c4429f4f855211" }, "downloads": -1, "filename": "wsgi_listener-0.1.tar.gz", "has_sig": false, "md5_digest": "8478e68648c1d34e368e6624fe5c735e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8800, "upload_time": "2019-10-20T19:38:08", "url": "https://files.pythonhosted.org/packages/95/64/339a2383a35aa9cf95b7e99abc804bd7c643905ae6d72c3b6373175172b3/wsgi_listener-0.1.tar.gz" } ] }