{ "info": { "author": "Ryan Richard", "author_email": "ryan@kumoru.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries", "Topic :: System :: Logging" ], "description": "=============\nlogformatjson\n=============\n\n``logformatjson`` is a library that provides a simple JSON formatter for the standard python logging package. It allows for nested arbitrary metadata to be inserted at instantiation and run time. The library is opionanted but attempts to allow most opinions to be overridden.\n\n**warning**: This library is under active development. The log format and API are expected to change.\n\n.. image:: https://circleci.com/gh/kumoru/logformatjson.svg?style=svg\n :target: https://circleci.com/gh/kumoru/logformatjson\n\n\nInstall\n-------\n\n* via ``pip``:\n\n.. code-block:: shell\n\n pip install logformatjson\n\nExamples\n========\n\n1. basic usage - JSONFormatter can be set on any handler as your would expect:\n\n.. code-block:: python\n\n import logging\n import sys\n from logformatjson import JSONFormatter\n\n LOGGER = logging.getLogger()\n LOGGER.setLevel(logging.DEBUG)\n log_handler = logging.StreamHandler(sys.stdout)\n log_handler.setFormatter(JSONFormatter())\n LOGGER.addHandler(log_handler)\n\n LOGGER.debug('this is my debug message', extra={'some_key': 'important_value'})\n\nwhich produces the following json (from ipython):\n\n.. code-block:: javascript\n\n {\n \"timestamp\": \"2016-02-19T19:39:17.061886\",\n \"message\": \"this is my debug message\",\n \"levelname\": \"DEBUG\",\n \"metadata\": {\n \"filename\": \"test.py\",\n \"funcName\": \"\",\n \"extra\": {\n \"some_key\": \"important_value\"\n },\n \"log_type\": \"python\",\n \"lineno\": 11,\n \"module\": \"test\",\n \"pathname\": \"test.py\"\n },\n \"log_version\": \"1.0\"\n }\n\n2. Adding an additional metadata in **every** log entry:\n\n.. code-block:: python\n\n \u2026\n log_handler.setFormatter(JSONFormatter(metadata={'application_version': '1.0.0'}))\n \u2026\n\n3. Overriding the defaults at instantiation:\n\n * Override attributes copied or skipped from the LogRecord_:\n .. code-block:: python\n\n \u2026\n log_handler.setFormatter(JSONFormatter(kept_attrs= ['created', \u2026]))\n log_handler.setFormatter(JSONFormatter(skipped_attrs= ['filename', \u2026]))\n \u2026\n\n * Override the provided json encoder:\n\n .. code-block:: python\n\n def my_json_encoder(obj):\n return int(obj)\n\n \u2026\n log_handler.setFormatter(JSONFormatter(json_encoder = my_json_encoder))\n \u2026\n\n\n\n\n4. Override the defaults at runtime:\n\n * Log type (intended to be mixed with extra fields):\n\n .. code-block:: python\n\n \u2026\n logger.debug('GET / HTTP/1.1', log_type='HTTP'}\n \u2026\n\n5. Extra fields:\n\n .. code-block:: python\n\n \u2026\n LOGGER.debug('this is my debug message', extra={'some_key': 'important_value'})\n \u2026\n\n\n.. _LogRecord: https://docs.python.org/3.4/library/logging.html#logrecord-attributes\n\nTests\n=====\n\nTests can be run via ``make``:\n\n.. code-block:: shell\n\n make lint\n make test\n\nAuthors\n=======\n* Ryan Richard ", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kumoru/logformatjson", "keywords": "formatter,json,logging", "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "logformatjson", "package_url": "https://pypi.org/project/logformatjson/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/logformatjson/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/kumoru/logformatjson" }, "release_url": "https://pypi.org/project/logformatjson/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Json formatter for logging", "version": "0.1.0" }, "last_serial": 1999651, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "e22a96ec66d9b1ca6920fb6c1b018eb0", "sha256": "be674184222de6b3c28a76fcebf72e96b45c6e81e4a9e80c310fd67d0e323a63" }, "downloads": -1, "filename": "logformatjson-0.0.2.tar.gz", "has_sig": true, "md5_digest": "e22a96ec66d9b1ca6920fb6c1b018eb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4220, "upload_time": "2016-02-19T21:13:18", "url": "https://files.pythonhosted.org/packages/f8/1e/703401e26324dc0a795dc08d79fb0624618d494a7bfe235273d9747155fb/logformatjson-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e468d789dbf8a1744757f3d4ba178b7a", "sha256": "019b16e6c92c5fd2b38a1eed0ac86176bdf614e342aa832e3e2b9221883697fc" }, "downloads": -1, "filename": "logformatjson-0.0.3.tar.gz", "has_sig": true, "md5_digest": "e468d789dbf8a1744757f3d4ba178b7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4217, "upload_time": "2016-02-19T21:21:32", "url": "https://files.pythonhosted.org/packages/03/ad/a2c3af6686ec99c3a640152eedb8cfea476db61293e7aeb6ea509f9c6d0c/logformatjson-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "f82f1d0fd4fc40baa161e4a45a8db052", "sha256": "7b28849f862e2ad08017d73267fb1208d60ef3e10cc60ce858e47a7bc3265483" }, "downloads": -1, "filename": "logformatjson-0.1.0.tar.gz", "has_sig": true, "md5_digest": "f82f1d0fd4fc40baa161e4a45a8db052", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4723, "upload_time": "2016-03-10T16:28:00", "url": "https://files.pythonhosted.org/packages/11/e9/40a8d955b069a3c70b6257eb4ff69e98bee6cde23fe50108aabcfdc112aa/logformatjson-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f82f1d0fd4fc40baa161e4a45a8db052", "sha256": "7b28849f862e2ad08017d73267fb1208d60ef3e10cc60ce858e47a7bc3265483" }, "downloads": -1, "filename": "logformatjson-0.1.0.tar.gz", "has_sig": true, "md5_digest": "f82f1d0fd4fc40baa161e4a45a8db052", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4723, "upload_time": "2016-03-10T16:28:00", "url": "https://files.pythonhosted.org/packages/11/e9/40a8d955b069a3c70b6257eb4ff69e98bee6cde23fe50108aabcfdc112aa/logformatjson-0.1.0.tar.gz" } ] }