{ "info": { "author": "Simeon Visser", "author_email": "simeonvisser@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: System :: Logging" ], "description": "logaugment\r\n==========\r\n\r\nPython logging library for augmenting log records with additional information.\r\n\r\nThis library supports Python 2.7.x and Python 3.1+.\r\n\r\nIf you want custom keys in your logged string:\r\n\r\n.. code:: python\r\n\r\n formatter = logging.Formatter(\"%(message)s: %(custom_key)s\")\r\n\r\nthen this library allows you to set them easily:\r\n\r\n.. code:: python\r\n\r\n logaugment.set(logger, custom_key='custom_value')\r\n logger.warn(\"My message\")\r\n # My message: custom_value\r\n\r\nThis allows you to safely make logging calls without getting exceptions\r\nthat those keys are missing. See below if you wish to override the value\r\nfor a particular logging call.\r\n\r\nInstallation\r\n============\r\n\r\nYou can install the library with pip:\r\n\r\n.. code:: bash\r\n\r\n $ pip install logaugment\r\n\r\nOverview\r\n========\r\n\r\nThis library provides three functions:\r\n\r\n.. code:: python\r\n\r\n # Sets the custom keys and values for the logger.\r\n logaugment.set(logger, custom_key='custom_value')\r\n\r\n # Adds custom keys and values in addition to those already set.\r\n logaugment.add(logger, custom_key='custom_value')\r\n\r\n # Removes all custom keys and values for the logger.\r\n logaugment.reset(logger)\r\n\r\nYou can use `logaugment.set` to specify custom values for a given logger.\r\n\r\nYou can use `logaugment.add` to keep the custom values that were already\r\nset and add new ones. If you're redefining a custom key / value then this\r\nvalue will be used instead of the earlier value. You should not repeatedly\r\ncall `logaugment.add` just to change the value; in that case it's better\r\nto use `logaugment.set`.\r\n\r\nYou can use `logaugment.reset` to remove all additional values that\r\nwere added using the `logaugment` library.\r\n\r\nWhy?\r\n====\r\n\r\nIf you need to add custom keys to your Python logging strings you need to pass\r\nthem in with each logging call. That is inconvenient so this library allows you\r\nto add values just once and they're then available for all logging calls\r\nafterwards.\r\n\r\nHere is a full example:\r\n\r\n.. code:: python\r\n\r\n import logging\r\n\r\n import logaugment\r\n\r\n logger = logging.getLogger()\r\n handler = logging.StreamHandler()\r\n formatter = logging.Formatter(\"%(message)s: %(custom_key)s\")\r\n handler.setFormatter(formatter)\r\n logger.addHandler(handler)\r\n\r\n logaugment.add(logger, custom_key='custom_value')\r\n logger.warn(\"My message\")\r\n # My message: custom_value\r\n\r\nExamples\r\n========\r\n\r\nYou can use keywords to specify additional values:\r\n\r\n.. code:: python\r\n\r\n logaugment.add(logger, custom_key='custom_value')\r\n logger.warn(\"My message\")\r\n # My message: custom_value\r\n\r\nYou can also use a dictionary or subclasses of collections.Mapping\r\nto specify the keys / values:\r\n\r\n.. code:: python\r\n\r\n logaugment.add(logger, {'custom_key': 'custom_value'})\r\n logger.warn(\"My message\")\r\n # My message: custom_value\r\n\r\nYou can also use a function which returns a dictionary:\r\n\r\n.. code:: python\r\n\r\n def process_record(record):\r\n return {'custom_key': record.levelname}\r\n\r\n logaugment.add(logger, process_record)\r\n logger.warn(\"My message\")\r\n # My message: WARNING\r\n\r\nYou can pass an `extra` dictionary in the call which overrides the\r\naugmented data:\r\n\r\n.. code:: python\r\n\r\n logaugment.add(logger, {'custom_key': 'custom_value'})\r\n logger.warn(\"My message\", extra={'custom_key': 'extra_value'})\r\n # My message: extra_value\r\n\r\n\r\nChangelog\r\n=========\r\n\r\n0.1.3 (September 28, 2014)\r\n----------------\r\n\r\n* Added check to ensure at least one argument is provided.\r\n\r\n0.1.2 (September 18, 2014)\r\n--------------------------\r\n\r\n* Added logaugment.set which calls reset() and add() in order.\r\n* Make logaugment.add work for all collections.Mapping instances.\r\n\r\n0.1.1 (September 8, 2014)\r\n-------------------------\r\n\r\n* Fixed issue where most recent value was not used\r\n in subsequent logaugment.add calls.\r\n* Added logaugment.reset to undo all additions using logaugment.\r\n\r\n0.1 (August 30, 2014)\r\n---------------------\r\n\r\n* Initial release.", "description_content_type": null, "docs_url": null, "download_url": "https://pypi.python.org/pypi/logaugment", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/svisser/logaugment", "keywords": "python custom logging keys keywords values", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "logaugment", "package_url": "https://pypi.org/project/logaugment/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/logaugment/", "project_urls": { "Download": "https://pypi.python.org/pypi/logaugment", "Homepage": "https://github.com/svisser/logaugment" }, "release_url": "https://pypi.org/project/logaugment/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Python logging library for augmenting log records with additional information", "version": "0.1.3" }, "last_serial": 1530327, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d24b17dc079d1a571672aec49e1e0cd3", "sha256": "dacbe3ca1a5b7373b74742d550c73933bdb6bffd3f8823e1b3cce2111fb07ede" }, "downloads": -1, "filename": "logaugment-0.1.tar.gz", "has_sig": false, "md5_digest": "d24b17dc079d1a571672aec49e1e0cd3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3166, "upload_time": "2014-08-30T01:04:20", "url": "https://files.pythonhosted.org/packages/a6/3e/94ea5f591126c412e9d17b519fcfe81f8cf3455efcdec22a3e40cd7345b9/logaugment-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "244f7d47bb80a23a8daaef0cad777d7a", "sha256": "7338c35b908cc04d255a22308383418e1b6b265a8f7ce62553815801c7391e00" }, "downloads": -1, "filename": "logaugment-0.1.1.tar.gz", "has_sig": false, "md5_digest": "244f7d47bb80a23a8daaef0cad777d7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3769, "upload_time": "2014-09-08T21:08:01", "url": "https://files.pythonhosted.org/packages/75/c3/29379d0e85e5e952949adcef354c274085452c73cf01558ce5eedb5dae37/logaugment-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "94fefd0c00a736eafe1bf55dc9c4b0df", "sha256": "8a934d72e485eb110599bcdb4e64e4468cb4b4ab824ffd890c441b7ab8b82dee" }, "downloads": -1, "filename": "logaugment-0.1.2.tar.gz", "has_sig": false, "md5_digest": "94fefd0c00a736eafe1bf55dc9c4b0df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4105, "upload_time": "2014-09-18T15:53:17", "url": "https://files.pythonhosted.org/packages/c0/fe/1822507e2db73eaceef95bd929211cf38763f7c1bc7a7528af001c9f1838/logaugment-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "7d0dcff87b7daef38a45e190ff08105b", "sha256": "e7af7b8aae3470f8497c39bd96e5bf564e7b9fd0932552e3ec73e0aca66830f0" }, "downloads": -1, "filename": "logaugment-0.1.3.tar.gz", "has_sig": false, "md5_digest": "7d0dcff87b7daef38a45e190ff08105b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4322, "upload_time": "2014-09-27T23:43:31", "url": "https://files.pythonhosted.org/packages/3e/5b/99d569af5fcc188ffd34f2cac0925820cf22966891897ce69a4aa5196241/logaugment-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7d0dcff87b7daef38a45e190ff08105b", "sha256": "e7af7b8aae3470f8497c39bd96e5bf564e7b9fd0932552e3ec73e0aca66830f0" }, "downloads": -1, "filename": "logaugment-0.1.3.tar.gz", "has_sig": false, "md5_digest": "7d0dcff87b7daef38a45e190ff08105b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4322, "upload_time": "2014-09-27T23:43:31", "url": "https://files.pythonhosted.org/packages/3e/5b/99d569af5fcc188ffd34f2cac0925820cf22966891897ce69a4aa5196241/logaugment-0.1.3.tar.gz" } ] }