{ "info": { "author": "Derrick Gilland", "author_email": "dgilland@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Logging" ], "description": "***************\nFlask-LogConfig\n***************\n\n|version| |travis| |coveralls| |license|\n\nFlask extension for configuring Python logging module.\n\n\nRequirements\n============\n\n\nCompatibility\n-------------\n\n- Python 2.6\n- Python 2.7\n- Python 3.3\n- Python 3.4\n\n\nDependencies\n------------\n\n- `Flask `_\n- `logconfig `_\n\n\nInstallation\n============\n\n\n::\n\n pip install Flask-LogConfig\n\n\nQuickstart\n==========\n\nUse ``Flask-LogConfig`` to easily configure the Python logging module using your Flask app's ``config`` object:\n\n\n.. code-block:: python\n\n import flask\n from flask.ext.logconfig import LogConfig\n\n class MyConfig(object):\n LOGCONFIG = {\n 'version': 1,\n 'disable_existing_loggers': False,\n 'formatters': {\n 'simple': {\n '()': 'myapp.logging.simple_formatter_factory'\n },\n 'email': {\n '()': 'myapp.logging.email_formatter_factory'\n }\n },\n 'filters': {\n 'email': {\n '()': 'myapp.logging.RequestFilter'\n }\n },\n 'handlers': {\n 'smtp': {\n 'class': 'logging.handlers.SMTPHandler',\n 'level': 'ERROR',\n 'formatter': 'email',\n 'filters': ['email'],\n 'mailhost': ('example.com', 587),\n 'fromaddr': 'Mailer ',\n 'toaddrs': ['admins@example.com'],\n 'subject': 'Application Error',\n 'credentials': ('mailer@example.com', 'password'),\n 'secure': ()\n },\n 'console': {\n 'class': 'logging.StreamHandler',\n 'level': 'DEBUG',\n 'formatter': 'simple',\n 'stream': 'ext://sys.stderr'\n }\n },\n 'loggers': {\n 'myapp': {\n 'handlers': ['smtp', 'console'],\n 'level': 'DEBUG'\n }\n }\n }\n\n LOGCONFIG_QUEUE = ['myapp']\n\n app = flask.Flask(__name__)\n app.config.from_object(MyConfig)\n logcfg = LogConfig(app)\n\n # or using lazy instantiation\n logcfg = LogConfig()\n logcfg.init_app(app)\n\n\nConfiguration\n=============\n\nConfiguration of Python's logging module is specified using the standard ``dictConfig`` or ``fileConfig`` formats supported by `logging.config `_. This allows Flask apps to be configured as one would in a Django app that uses `logging `__.\n\n\nLOGCONFIG\n---------\n\nThe main configuration option for ``Flask-LogConfig`` is ``LOGCONFIG``. This option can either be a ``dict`` or a pathname to a configuration file. The format of the ``dict`` or config file must follow the format supported by ``logging.config.dictConfig`` or ``loging.config.fileConfig``. See `Logging Configuration `_ for more details. If using a pathname, the supported file formats are ``JSON``, ``YAML``, and ``ConfigParser``.\n\n\nLOGCONFIG_QUEUE\n---------------\n\nThe purpose of ``LOGCONFIG_QUEUE`` is to provide an easy way to utilize logging without blocking the main thread.\n\nTo set up a basic logging queue, specify the loggers you want to queuify by setting ``LOGCONFIG_QUEUE`` to a list of the logger names (as strings). These loggers will have their handlers moved to a queue which will then be managed by a queue handler and listener, one per logger.\n\nEach logger's queue handler will be an instance of ``flask_logconfig.FlaskQueueHandler`` which is an extension of `logging.handlers.QueueHandler `_ (back ported to Python 2 via `logutils `_). ``FlaskQueueHandler`` adds a copy of the current request context to the log record so that the queuified log handlers can access any Flask request globals outside of the normal request context (i.e. inside the listener thread) via ``flask_logconfig.request_context_from_record``. The queue listener used is an instance of `logconfig.QueueListener `_ that extends `logging.handlers.QueueListener `_ with proper support for respecting a handler's log level (i.e. ``logging.handlers.QueueListener`` delegates all log records to a handler even if that handler's log level is set higher than the log record's while ``logconfig.QueueListener`` does not).\n\nAfter the log handlers are queuified, their listener thread will be started automatically unless you specify otherwise. You can access the listeners via the ``LogConfig`` instance:\n\n\n.. code-block:: python\n\n logcfg = LogConfig()\n\n # start_listeners=True by default\n logcfg.init_app(app, start_listeners=False)\n\n assert isinstance(logcfg, list)\n\n # start listeners manually\n logcfg.start_listeners(app)\n\n # stop listeners\n logcfg.stop_listeners(app)\n\n\nSee the `Log Record Request Context`_ section for details on accessing an application's request context from within a queue.\n\n\nLOGCONFIG_REQUESTS_ENABLED\n--------------------------\n\nWhen set to ``True``, ``LOGCONFIG_REQUESTS_ENABLED`` turns on logging for all requests. Defaults to ``False``.\n\nRequests will be logged at the end of the request via the ``app.after_request`` hook. In addition to providing a custom log msg, additional ``extra`` arguments will be passed to the logging call:\n\n- ``response``\n- ``request``\n\nThese can later be accessed from the log record via ``record.response`` and ``record.request``. This provides a convenient way for the log filters, handlers, and formatters to access request/response specific data.\n\n\nLOGCONFIG_REQUESTS_LOGGER\n-------------------------\n\nThe logger name to use when logging all requests. Defaults to ``None`` which uses ``app.logger``.\n\n\nLOGCONFIG_REQUESTS_LEVEL\n------------------------\n\nThe log level at which to log all requests. Defaults to ``logging.DEBUG``.\n\n\nLOGCONFIG_REQUESTS_MSG_FORMAT\n-----------------------------\n\nThe message format used to generate the ``msg`` argument to ``log()`` when logging all requests. Defaults to ``'{method} {path} - {status_code}'``.\n\nWhen generating the message, ``LOGCONFIG_REQUESTS_MSG_FORMAT.format(**kargs)`` will be called with the following keyword arguments:\n\n\nFrom request.environ\n++++++++++++++++++++\n\n- ``SERVER_PORT``\n- ``SERVER_PROTOCOL``\n- ``SCRIPT_NAME``\n- ``REQUEST_METHOD``\n- ``HTTP_HOST``\n- ``PATH_INFO``\n- ``QUERY_STRING``\n- ``CONTENT_LENGTH``\n- ``SERVER_NAME``\n- ``CONTENT_TYPE``\n\n**NOTE:** Additional data may be available depending on the WSGI environment provided.\n\nFrom request\n++++++++++++\n\n- ``method``\n- ``path``\n- ``base_url``\n- ``url``\n- ``remote_addr``\n- ``user_agent``\n\nFrom response\n+++++++++++++\n\n- ``status_code``\n- ``status``\n\nFrom flask\n++++++++++\n\n- ``session``\n\n**NOTE:** The ``session`` argument is a computed as follows:\n\n\n.. code-block:: python\n\n from collections import defaultdict\n from flask import session\n\n session_data = defaultdict(lambda: None)\n session_data.update(dict(session)\n\n\nThis means that you can safely access ``session`` values even if they aren't explictly set. When they are missing, ``None`` will be returned instead.\n\nFrom computed\n+++++++++++++\n\n- ``execution_time`` (in milliseconds) **NOTE:** This is the time between the start of the request and then end.\n\n\nLog Record Request Context\n==========================\n\nWhen using ``LOGCONFIG_QUEUE``, accessing Flask's request globals from within a log handler requires using the request context that is attached to the emitted log record.\n\nBelow is an example that uses a logging ``Filter`` to attach the request environment to the log record using ``flask_logconfig.request_context_from_record``:\n\n\n.. code-block:: python\n\n import logging\n from pprint import pformat\n from flask import request\n\n from flask_logconfig import request_context_from_record\n\n class RequestFilter(logging.Filter):\n \"\"\"Impart contextual information related to Flask HTTP request.\"\"\"\n def filter(self, record):\n \"\"\"Attach request contextual information to log record.\"\"\"\n with request_context_from_record(record):\n record.environ_info = request.environ.copy()\n record.environ_text = pformat(record.environ_info)\n return True\n\n\nIt's also safe to use ``request_context_from_record`` from directly inside Flask's request context:\n\n\n.. code-block:: python\n\n\n with request_context_from_record():\n # do something using Flask request globals\n pass\n\n\nIf no request context exists (either on the log record provided or inside the actual Flask request context), then a ``flask_logconfig.FlaskLogConfigException`` will be thrown.\n\n\n.. |version| image:: http://img.shields.io/pypi/v/flask-logconfig.svg?style=flat\n :target: https://pypi.python.org/pypi/flask-logconfig/\n\n.. |travis| image:: http://img.shields.io/travis/dgilland/flask-logconfig/master.svg?style=flat\n :target: https://travis-ci.org/dgilland/flask-logconfig\n\n.. |coveralls| image:: http://img.shields.io/coveralls/dgilland/flask-logconfig/master.svg?style=flat\n :target: https://coveralls.io/r/dgilland/flask-logconfig\n\n.. |license| image:: http://img.shields.io/pypi/l/flask-logconfig.svg?style=flat\n :target: https://pypi.python.org/pypi/flask-logconfig/", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dgilland/flask-logconfig", "keywords": "flask logging config configuration", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "Flask-LogConfig", "package_url": "https://pypi.org/project/Flask-LogConfig/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Flask-LogConfig/", "project_urls": { "Homepage": "https://github.com/dgilland/flask-logconfig" }, "release_url": "https://pypi.org/project/Flask-LogConfig/0.4.2/", "requires_dist": null, "requires_python": null, "summary": "Flask extension for configuring Python logging module", "version": "0.4.2" }, "last_serial": 1655049, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "062e52a348ef2d5051a114945e857c2c", "sha256": "d17e4b8ced6655ec5f29b4e648ff6a5a39bc7234079bc18038e361e0c2c81861" }, "downloads": -1, "filename": "Flask_LogConfig-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "062e52a348ef2d5051a114945e857c2c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8927, "upload_time": "2014-12-25T04:37:27", "url": "https://files.pythonhosted.org/packages/d9/47/aa72ed9f3defccc334eff8fdb46542fc2d015b03f611ca6369308ba546b2/Flask_LogConfig-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f91e88cbd3c65e60d2e38a944a44d414", "sha256": "bc232e62a65ee9e75bc5a45ecdb21c3fa8642e51ab7102f493a654d4741a676b" }, "downloads": -1, "filename": "Flask-LogConfig-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f91e88cbd3c65e60d2e38a944a44d414", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6669, "upload_time": "2014-12-25T04:37:24", "url": "https://files.pythonhosted.org/packages/6d/fd/7d780e586637c13cc61dca20df4187da967860fd478578117c090e61eb8e/Flask-LogConfig-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ce4c64f2377573ac0dfd43c6c710c591", "sha256": "b221557704cf8823aa34698bc655bc901a09f47d21c74aefed15987a32b70197" }, "downloads": -1, "filename": "Flask_LogConfig-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ce4c64f2377573ac0dfd43c6c710c591", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9036, "upload_time": "2015-01-23T02:33:26", "url": "https://files.pythonhosted.org/packages/c8/a6/520f813c190b738a12164586c04b1d7c8ae9608a63715a6d7cad3b6c3364/Flask_LogConfig-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "865f95880857cbda09087ecf3dc9068c", "sha256": "e026894f6d231a3643c29703a51884e0cb9d6ca4f0b43b763fe2f1fba7d6752c" }, "downloads": -1, "filename": "Flask-LogConfig-0.2.0.tar.gz", "has_sig": false, "md5_digest": "865f95880857cbda09087ecf3dc9068c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6835, "upload_time": "2015-01-23T02:33:24", "url": "https://files.pythonhosted.org/packages/4a/78/9d9f1a5327cb11438d710875a0edd1dabb45b58ac1f516bd9c4583ae9bfc/Flask-LogConfig-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "26351078ba29d04366ce1661cb58a208", "sha256": "0e22f5b188a74ddf73c7a1aee8a19e6f96a985ffb8671e856046ced5e64aad91" }, "downloads": -1, "filename": "Flask_LogConfig-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "26351078ba29d04366ce1661cb58a208", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11497, "upload_time": "2015-01-25T18:45:51", "url": "https://files.pythonhosted.org/packages/a0/d5/93e439a0cc6e98489a951f700160d4d1458aa90376c90e74a7fc6fa6e97d/Flask_LogConfig-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b0b59aea2b6483fe14694809f903a13", "sha256": "2fadfc6ac4e09fad56de6ae99ad72d0cc0b7ae57abb0fd8a7ff66d136e063a7c" }, "downloads": -1, "filename": "Flask-LogConfig-0.3.0.tar.gz", "has_sig": false, "md5_digest": "9b0b59aea2b6483fe14694809f903a13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8869, "upload_time": "2015-01-25T18:45:40", "url": "https://files.pythonhosted.org/packages/86/76/c9cabd1066a188a8671faa2a939b9e90ae3646a49ce6e4a415cae1d0ef5b/Flask-LogConfig-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "4c2b9c9110d1062aa494d03924efef17", "sha256": "67edbf46ce8537ab7ad5576379a6c4d56e52018a0a829b79a8578290ad59d8b7" }, "downloads": -1, "filename": "Flask_LogConfig-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4c2b9c9110d1062aa494d03924efef17", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12130, "upload_time": "2015-02-04T03:49:29", "url": "https://files.pythonhosted.org/packages/6d/90/cbf5ecce27aba98246759508996ea3741b3d74660a19c017b8aa2fa30e0e/Flask_LogConfig-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d69297631f09a33904b3f6c573a156c", "sha256": "c3b7fc16eb26912f7a82284dbe55af8663965db14052ed98262012c41009deab" }, "downloads": -1, "filename": "Flask-LogConfig-0.4.0.tar.gz", "has_sig": false, "md5_digest": "2d69297631f09a33904b3f6c573a156c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12472, "upload_time": "2015-02-04T03:49:25", "url": "https://files.pythonhosted.org/packages/0f/70/37a16c26ed4e9d49dcf7a8fd758970a46eabd44c9124f3ef16988b88038f/Flask-LogConfig-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "fd28790decdd1a59dbee1e3af49936c9", "sha256": "4c0ed3977a0e24f20cfc3155b3b3eab3a92196f67d7d0ee683ff10275788bbd8" }, "downloads": -1, "filename": "Flask_LogConfig-0.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fd28790decdd1a59dbee1e3af49936c9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12136, "upload_time": "2015-05-21T03:57:46", "url": "https://files.pythonhosted.org/packages/19/bf/9f0d8ec996b143c760d7366ff753fcfafb0cea1f8f2d51803110e5f54b15/Flask_LogConfig-0.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c85b9f736bcaf506406550151db80ed2", "sha256": "6394710e5900a96e9c874690e3eb1c7f549cca33509c8311f579d16997e8cca5" }, "downloads": -1, "filename": "Flask-LogConfig-0.4.1.tar.gz", "has_sig": false, "md5_digest": "c85b9f736bcaf506406550151db80ed2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12512, "upload_time": "2015-05-21T03:57:43", "url": "https://files.pythonhosted.org/packages/7a/53/c84cc043415bb402459a6cd166f7f3535bd2195f89072046cd6c146f9e15/Flask-LogConfig-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "fad9029181b27aa0d96c0fccc3058eae", "sha256": "a301b56a3ca7dc49302a11206799962dd51c1e6c172ee9ebf59abfd56cef3a43" }, "downloads": -1, "filename": "Flask_LogConfig-0.4.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fad9029181b27aa0d96c0fccc3058eae", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12385, "upload_time": "2015-07-29T13:33:54", "url": "https://files.pythonhosted.org/packages/b9/a3/e5b0c3df47179900e3a9c16a73195cdb20fb6ee950b21781657b4813a0b6/Flask_LogConfig-0.4.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "04d3575e2d9081c18c8612662190c12b", "sha256": "802cb98aa2b8a2cf89d6b6fd5c7673c8e3129f5147ac05396984dcf0645bf594" }, "downloads": -1, "filename": "Flask-LogConfig-0.4.2.tar.gz", "has_sig": false, "md5_digest": "04d3575e2d9081c18c8612662190c12b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12672, "upload_time": "2015-07-29T13:33:51", "url": "https://files.pythonhosted.org/packages/c4/8e/49ae35ce5d30f352e9e923a98e6e091342dd3f351f8b2fbcdef21116dbcc/Flask-LogConfig-0.4.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fad9029181b27aa0d96c0fccc3058eae", "sha256": "a301b56a3ca7dc49302a11206799962dd51c1e6c172ee9ebf59abfd56cef3a43" }, "downloads": -1, "filename": "Flask_LogConfig-0.4.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fad9029181b27aa0d96c0fccc3058eae", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12385, "upload_time": "2015-07-29T13:33:54", "url": "https://files.pythonhosted.org/packages/b9/a3/e5b0c3df47179900e3a9c16a73195cdb20fb6ee950b21781657b4813a0b6/Flask_LogConfig-0.4.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "04d3575e2d9081c18c8612662190c12b", "sha256": "802cb98aa2b8a2cf89d6b6fd5c7673c8e3129f5147ac05396984dcf0645bf594" }, "downloads": -1, "filename": "Flask-LogConfig-0.4.2.tar.gz", "has_sig": false, "md5_digest": "04d3575e2d9081c18c8612662190c12b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12672, "upload_time": "2015-07-29T13:33:51", "url": "https://files.pythonhosted.org/packages/c4/8e/49ae35ce5d30f352e9e923a98e6e091342dd3f351f8b2fbcdef21116dbcc/Flask-LogConfig-0.4.2.tar.gz" } ] }