{ "info": { "author": "Jeff Dairiki", "author_email": "dairiki@dairiki.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Pyramid", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP", "Topic :: System :: Logging" ], "description": "##################################\nRequest Attributes in Log Messages\n##################################\n\n|version| |py_versions| |py_implementation| |license| |build status|\n\nWhat It Does\n============\n\nThe `pyramid_log`_ distribution includes a Python `logging formatter`_\nwhich makes Pyramid_ request attributes available for use in its\nformat string. Specifically, ``pyramid_log.Formatter`` is special in\nthe following ways:\n\n- It sets a ``.request`` attribute on the log record (if one doesn\u2019t\n already exist.)\n\n- It supports dotted attribute access in its format string. For\n example, ``\"%(request.method)s\"`` and even\n ``\"%(request.matched_route.name)s\"`` will work in the format string.\n\n- There is a syntax for explicitly specifying fallback values. For\n example, a format string of ``\"%(request.method|)s\"``\n will format to ``\"\"`` if there is no current request (or\n if the current request has no ``method`` attribute.)\n\nThe pyramid request has many attributes which can be useful when included\nin the logs of a web app. These include, but are not limited to:\n\n- ``request.method``\n- ``request.url`` (or ``request.path``, ``request.path_qs``, etc\u2026)\n- ``request.unauthenticated_userid``\n- ``request.client_addr``\n- ``request.GET`` (or ``request.POST`` or ``request.params``)\n- ``request.matched_route.name``, ``request.view_name``\n\nSee the `Pyramid documentation `_ for a more\ncomplete list of available request attributes.\n\n.. _pyramid_log: https://pypi.python.org/pypi/pyramid_log/\n.. _logging formatter:\n https://docs.python.org/3/library/logging.html#formatter-objects\n.. _pyramid: http://docs.pylonsproject.org/projects/pyramid/en/latest/\n.. _pyramid.request:\n http://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html\n\n\nInstallation\n============\n\nThe distribution may be downloaded from pypi_, but it may be easier to\ninstall using pip_::\n\n pip install pyramid-log\n\nIt has been tested on python 2.7, 3.4\u20133.6 and pypy.\n\nDevelopment happens at https://github.com/dairiki/pyramid_log/.\n\n.. _pypi: `logging formatter`_\n.. _pip: https://pip.pypa.io/en/latest/\n\n\nConfiguration\n=============\n\nConfiguring Logging in a File\n-----------------------------\n\nIf you configure logging in your application configuration (or some\nother) file you can do something like::\n\n [loggers]\n key = root\n\n [handlers]\n keys = console\n\n [formatters]\n keys = pyramid\n\n [logger_root]\n level = INFO\n handlers = console\n\n [handler_console]\n class = StreamHandler\n args = (sys.stderr,)\n level = NOTSET\n formatter = pyramid\n\n [formatter_pyramid]\n # NB: Here is the interesting part!\n class = pyramid_log.Formatter\n format = %(asctime)s %(request.method|no request)s %(request.path_qs|)s\n %(levelname)-5.5s [%(name)s] %(message)s\n\nThis will result in your log messages looking something like::\n\n 2014-10-01 17:55:02,001 GET /path?arg=foo\n WARNI [myapp.views] This is some log message!\n\nRefer to Pyramid\u2019s `chapter on logging`_ and the documentation for the\nPython logging_ module\u2019s `configuration file format`_ for more details\non how this works.\n\n.. _chapter on logging:\n http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html\n.. _logging:\n https://docs.python.org/3/library/logging.html\n.. _configuration file format:\n https://docs.python.org/3/library/logging.config.html#logging-config-fileformat\n\n\nImperative Configuration\n------------------------\n\nYou can of course configure logging imperatively. For example, with::\n\n import logging\n from pyramid_log import Formatter\n\n fmt = Formatter(\n '%(asctime)s %(request.client_addr|-)s'\n ' %(request.method|-)s %(request.path_qs|-)s: %(message)s')\n\n logging.basicConfig()\n root_logger = logging.getLogger()\n for handler in root_logger.handlers:\n handler.setFormatter(fmt)\n\nThen, a view can log a message like so::\n\n log = logging.getLogger(__name__)\n\n @view_config(name='persimmon')\n def persimmon_view(request):\n log.warning(\"%s was called!\", request.view_name)\n\nWhich will yield a log message like::\n\n 2014-10-01 17:55:02,001 192.168.1.1 GET /persimmon: persimmon was called\n\n\nFurther Details\n===============\n\nAccessing Dict-like Values\n--------------------------\n\nThe dot notation can be used to access not only instance attributes,\nbut also to access items in ``dict``-like values. Attribute access is\ntried first; if there is no attribute of the given name, then the\ninstances ``__getitem__`` method is tried. For example,\n``\"%(request.matchdict.id)s\"`` will get at\n``request.matchdict['id']``.\n\nNumeric Fallback\n----------------\n\nExplicit fallback values are always interpreted as strings, however,\nif the fallback is used in a numeric context, an attempt will be made\nat conversion to the requested type. For example, if there is no\nrequest, ``\"%+(request.status_code|555)d\"`` will format to ``\"+555\"``.\n\nIf the fallback string can not be converted to a numeric value, then\n``0`` (zero) is used in integer contexts and NaN_ is used in ``float``\ncontexts.\n\n.. _NaN: https://en.wikipedia.org/wiki/NaN\n\nDefault Fallback Values\n-----------------------\n\nIf no fallback value is explicitly specified, then a default fallback\nvalue will be used if the requested attribute does not exist. The\nmissing attribute name is included in the default fallback value. For\nexample ``\"%(request.method)s\"`` will produce ``\"\"``\nif there is no current request.\n\n\nSee Also\n========\n\nThe `pyramid_logging`_ distribution provides similar functionality.\n\n.. _pyramid_logging: https://pypi.python.org/pypi/pyramid_logging\n\n\nAuthor\n======\n\nJeff Dairiki \n\n\n.. ==== Badges ====\n\n.. |build status| image::\n https://travis-ci.org/dairiki/pyramid_log.svg?branch=master\n :target: https://travis-ci.org/dairiki/pyramid_log\n\n.. |downloads| image::\n https://img.shields.io/pypi/dm/pyramid_log.svg\n :target: https://pypi.python.org/pypi/pyramid_log/\n :alt: Downloads\n.. |version| image::\n https://img.shields.io/pypi/v/pyramid_log.svg\n :target: https://pypi.python.org/pypi/pyramid_log/\n :alt: Latest Version\n.. |py_versions| image::\n https://img.shields.io/pypi/pyversions/pyramid_log.svg\n :target: https://pypi.python.org/pypi/pyramid_log/\n :alt: Supported Python versions\n.. |py_implementation| image::\n https://img.shields.io/pypi/implementation/pyramid_log.svg\n :target: https://pypi.python.org/pypi/pyramid_log/\n :alt: Supported Python versions\n.. |license| image::\n https://img.shields.io/pypi/l/pyramid_log.svg\n :target: https://github.com/dairiki/pyramid_log/blob/master/LICENSE\n :alt: License\n.. |dev_status| image::\n https://img.shields.io/pypi/status/pyramid_log.svg\n :target: https://pypi.python.org/pypi/pyramid_log/\n :alt: Development Status\n\n\nHistory\n=======\n\n\nRelease 0.2.1 (2017-12-17)\n--------------------------\n\nThis release officially drops support for python 2.6, 3.2, 3.3 (and theremore pypy3)\nand adds support for python 3.5 and 3.6.\n\nOther than changes in test configuration, there are no substantive\nchanges from `0.2`.\n\nRelease 0.2 (2014-10-09)\n------------------------\n\nFeatures\n^^^^^^^^\n\nBetter fallback values.\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n- Now, by default, if an attribute is missing (which can happen, e.g.,\n for ``%(request.method)s`` is there is no current request) it is\n rendered as ````\n (e.g. ``\"\"``.)\n\n- There is now a syntax for explicitly specifying fallback values. E.g.\n ``\"%(request.method|(no-request))\"`` which will format to ``(no request)``,\n if there is no current request (or if the current request does not have\n a ``method`` attribute.)\n\nDict-like access to values\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n- When looking up a dotted name, if an attribute can not be found,\n ``dict``-style (``__getitem__``) lookup will be attempted.\n E.g. ``\"%(request.matchdict.arg)\"`` will get at\n ``request.matchdict['arg']``.\n\nRelease 0.1.1 (2014-10-02)\n--------------------------\n\nBugs Fixed\n^^^^^^^^^^\n\n- If an exception is thrown by a request property, render it as ``None``.\n\n- Disable logging during log formatting to prevent recursion if a request\n property generates a log message.\n\nRelease 0.1 (2014-10-02)\n------------------------\n\n- Initial release\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/pyramid_log/", "keywords": "pyramid logging", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pyramid-log", "package_url": "https://pypi.org/project/pyramid-log/", "platform": "", "project_url": "https://pypi.org/project/pyramid-log/", "project_urls": { "Homepage": "http://pypi.python.org/pypi/pyramid_log/" }, "release_url": "https://pypi.org/project/pyramid-log/0.2.1/", "requires_dist": [ "pyramid" ], "requires_python": "", "summary": "Include pyramid request attributes in your log messages", "version": "0.2.1" }, "last_serial": 3424083, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4dccca1b01dd99076480c95a71e7a2e9", "sha256": "f983eafe05e577c6e8301689e684d277fa7745973ec162eed9fe8a8678b8dc35" }, "downloads": -1, "filename": "pyramid_log-0.1.tar.gz", "has_sig": true, "md5_digest": "4dccca1b01dd99076480c95a71e7a2e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6378, "upload_time": "2014-10-03T03:26:54", "url": "https://files.pythonhosted.org/packages/f8/d0/769bd3e5f8396232beaff2ca2c527565c5401f921aead21fdae0a56a08c0/pyramid_log-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "6541aa14c383c51d75ca3369c1a9b5ae", "sha256": "1619cd770391d531b206ce5075bec9000505cfe61cda1f27d2b696d29e9df3b7" }, "downloads": -1, "filename": "pyramid_log-0.1.1.tar.gz", "has_sig": true, "md5_digest": "6541aa14c383c51d75ca3369c1a9b5ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6907, "upload_time": "2014-10-03T06:10:10", "url": "https://files.pythonhosted.org/packages/f6/55/86983695416230d82747df05e58eea3d5e8afeace889064daba0eecd2be3/pyramid_log-0.1.1.tar.gz" } ], "0.1rc1": [], "0.2": [ { "comment_text": "", "digests": { "md5": "00365f9e960046b9a70e532cfee2caf7", "sha256": "336e5ecbe722f1ec22991aa6b44296b77c4432fecdf9028e09b4d56baaa11f21" }, "downloads": -1, "filename": "pyramid_log-0.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "00365f9e960046b9a70e532cfee2caf7", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 12561, "upload_time": "2014-10-09T19:51:31", "url": "https://files.pythonhosted.org/packages/fd/80/31553eecdfd8cd84cba9d0ba6d092633fcc91ceee49111c5a6569b2b6c0f/pyramid_log-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e2ba4c48e8208bf6af6b48d7b80a5893", "sha256": "adfac886d25900d5478c4d8a9ea572e5bf0859ce7fc130f2d462d2d3465cb3ce" }, "downloads": -1, "filename": "pyramid_log-0.2.tar.gz", "has_sig": true, "md5_digest": "e2ba4c48e8208bf6af6b48d7b80a5893", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12362, "upload_time": "2014-10-09T19:38:07", "url": "https://files.pythonhosted.org/packages/03/27/aeedfe310cc795492494b6cf18663fb3be10271489d13456e22b7b4ee7c0/pyramid_log-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "820ddb74ca5282527d685eebbcd07f52", "sha256": "9008dfe54e63b5213c002c68e1701db0627ced795bf754b8add33e1952503452" }, "downloads": -1, "filename": "pyramid_log-0.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "820ddb74ca5282527d685eebbcd07f52", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12736, "upload_time": "2017-12-18T04:01:32", "url": "https://files.pythonhosted.org/packages/4e/db/e888754cf3160c3ec1db7b8f7f4e4f1d88afc0447b8402237f4e74d2f3cf/pyramid_log-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1abd5b43c36fffb0f04a4bdfcb677901", "sha256": "165ce9460548b09061db6023b5079eb6290d9490a2b4cf28946e3515185d0a52" }, "downloads": -1, "filename": "pyramid_log-0.2.1.tar.gz", "has_sig": true, "md5_digest": "1abd5b43c36fffb0f04a4bdfcb677901", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12460, "upload_time": "2017-12-18T04:01:34", "url": "https://files.pythonhosted.org/packages/3a/84/2d55710c8610848df953ffb01a3a19022ccf251ac44163cd9f5541d95165/pyramid_log-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "820ddb74ca5282527d685eebbcd07f52", "sha256": "9008dfe54e63b5213c002c68e1701db0627ced795bf754b8add33e1952503452" }, "downloads": -1, "filename": "pyramid_log-0.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "820ddb74ca5282527d685eebbcd07f52", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12736, "upload_time": "2017-12-18T04:01:32", "url": "https://files.pythonhosted.org/packages/4e/db/e888754cf3160c3ec1db7b8f7f4e4f1d88afc0447b8402237f4e74d2f3cf/pyramid_log-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1abd5b43c36fffb0f04a4bdfcb677901", "sha256": "165ce9460548b09061db6023b5079eb6290d9490a2b4cf28946e3515185d0a52" }, "downloads": -1, "filename": "pyramid_log-0.2.1.tar.gz", "has_sig": true, "md5_digest": "1abd5b43c36fffb0f04a4bdfcb677901", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12460, "upload_time": "2017-12-18T04:01:34", "url": "https://files.pythonhosted.org/packages/3a/84/2d55710c8610848df953ffb01a3a19022ccf251ac44163cd9f5541d95165/pyramid_log-0.2.1.tar.gz" } ] }