{ "info": { "author": "Tony S Yu", "author_email": "tsyu80@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "===========\nlogquacious\n===========\n\n.. default-role:: literal\n\n.. image:: https://img.shields.io/pypi/v/logquacious.svg\n :target: https://pypi.python.org/pypi/logquacious\n\n.. image:: https://travis-ci.com/tonysyu/logquacious.svg?branch=master\n :target: https://travis-ci.com/tonysyu/logquacious\n\n.. image:: https://readthedocs.org/projects/logquacious/badge/?version=latest\n :target: https://logquacious.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n.. image:: https://codecov.io/gh/tonysyu/logquacious/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/tonysyu/logquacious\n\n\nLogquacious is a set of simple logging utilities to help you over-communicate.\n(Logorrhea would've been a good name, if it didn't sound so terrible.)\n\nGood application logging is easy to overlook, until you have to debug an error\nin production. Logquacious aims to make logging as easy as possible. You can\nfind read more at the official `ReadTheDocs documentation`_.\n\nQuick start\n-----------\n\nTo get started, first make sure logquacious is installed:\n\n.. code-block:: console\n\n $ pip install logquacious\n\nYou'll also need to set up logging for your application. For this\nexample, we'll use a really simple configuration:\n\n.. code-block:: python\n\n import logging\n\n logging.basicConfig(format='%(levelname)s: %(message)s',\n level=logging.DEBUG)\n\nNote that this simple configuration is used for demonstration purposes, only.\nSee the `Logging Cookbook`_ in the official Python docs for examples of\noptions used for real logging configuration.\n\nThe main interface to `logquacious` is the `LogManager`, which can be used for\nnormal logging:\n\n.. code-block:: python\n\n import logquacious\n\n log = logquacious.LogManager(__name__)\n\n.. ignore-next-block\n.. code-block:: python\n\n log.debug('Nothing to see here.')\n\nDue to our simplified logging format defined earlier, that would output:\n\n.. code-block:: console\n\n DEBUG: Nothing to see here.\n\nThat isn't a very interesting example. In addition to basic logging,\n`LogManager` has a `context` attribute for use as a context manager:\n\n.. code-block:: python\n\n >>> with log.context.debug('greetings'):\n ... print('Hello!')\n DEBUG: Enter greetings\n Hello!\n DEBUG: Exit greetings\n\nThe same attribute can be used as a decorator, as well:\n\n.. code-block:: python\n\n @log.context.info\n def divide(numerator, denominator):\n if denominator == 0:\n log.warning('Attempted division by zero. Returning None')\n return None\n return numerator / denominator\n\n >>> divide(1, 0)\n INFO: Call `divide()`\n WARNING: Attempted division by zero. Returning None\n INFO: Return from `divide`\n\nEven better, you can log input arguments as well:\n\n.. code-block:: python\n\n @log.context.info(show_args=True, show_kwargs=True)\n def greet(name, char='-'):\n msg = 'Hello, {name}'.format(name=name)\n print(msg)\n print(char * len(msg))\n\n >>> greet('Tony', char='~')\n INFO: Call `greet('Tony', char='~')`\n Hello, Tony\n ~~~~~~~~~~~\n INFO: Return from `greet`\n\nThere's also a special context manager for suppressing errors and logging:\n\n.. code-block:: python\n\n with log.and_suppress(ValueError, msg=\"It's ok, mistakes happen\"):\n raise ValueError('Test error')\n\n.. code-block:: console\n\n [ERROR] It's ok, mistakes happen\n Traceback (most recent call last):\n File \"/Users/tyu/code/logquacious/logquacious/log_manager.py\", line 103, in and_suppress\n yield\n File \"scripts/example.py\", line 26, in \n raise ValueError('Test error')\n ValueError: Test error\n\nNote the traceback above is logged, not streamed to stderr.\n\n\nConfiguration\n-------------\n\nThe message templates used by `LogManager.context` can be configured to your\nliking by passing a `context_templates` argument to `LogManager`:\n\n.. code-block:: python\n\n log = logquacious.LogManager(__name__, context_templates={\n 'context.start': '=============== Enter {label} ===============',\n 'context.finish': '=============== Exit {label} ===============',\n })\n\n with log.context.debug('greetings'):\n print('Hello!')\n\n.. code-block:: console\n\n [DEBUG] =============== Enter greetings ===============\n Hello!\n [DEBUG] =============== Exit greetings ===============\n\n\nThe general format for `context_templates` keys is::\n\n [CONTEXT_TYPE.]('start'|'finish')[.LOG_LEVEL_NAME]\n\nwhere square-brackets marks optional fields.\n\n`CONTEXT_TYPE` can be any of the following:\n\n- `function`: Template used when called as a decorator.\n- `context`: Template used when called as a context manager.\n\n`LOG_LEVEL_NAME` can be any of the following logging levels:\n\n- `DEBUG`\n- `INFO`\n- `WARNING`\n- `ERROR`\n- `CRITICAL`\n\nFor example, consider the cascade graph for `function.start.DEBUG`, which\nlooks like::\n\n function.start.DEBUG\n / \\\n start.DEBUG function.start\n \\ /\n start\n\nThe cascade is performed using a breadth-first search. If\n`function.start.DEBUG` is not defined, check `start.DEBUG` then check\n`function.start` *BEFORE* checking `start`.\n\nThe default configuration is:\n\n.. code-block:: python\n\n DEFAULT_TEMPLATES = {\n 'start': 'Enter {label}',\n 'finish': 'Exit {label}',\n 'function.start': 'Call `{label}({arguments})`',\n 'function.finish': 'Return from `{label}`',\n }\n\nNote that custom configuration *updates* these defaults. For example, if you\nwant to if you want to skip logging on exit for all context managers and\ndecorators, you'll have set *both* `'finish'` and `'function.finish'` to `None`\nor an empty string.\n\nAs you can see above, two template variables may be passed to the template\nstring: `label` and `arguments`. When called as a context manager, the `label`\nis the first argument to the context manager and `arguments` is always empty.\nWhen called as a decorator, `label` is the function's `__name__` and\n`arguments` a string representing input arguments, if `show_args` or\n`show_kwargs` parameters are `True`.\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the\n`audreyr/cookiecutter-pypackage`_ project template.\n\n\n.. _ReadTheDocs documentation: https://logquacious.readthedocs.io/en/latest/\n.. _Logging Cookbook: https://docs.python.org/3.6/howto/logging-cookbook.html\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.5.0 (2019-05-05)\n------------------\n\n- Backport `stacklevel` keyword argument from Python 3.8 and configure\n stacklevel such that logging utilities report the context (e.g. filename\n and line number) where `logquacious` utilities are called.\n\n0.4.0 (2018-10-05)\n------------------\n\n- Fix config override behavior to extend rather than replace default templates\n\n0.3.0 (2018-10-05)\n------------------\n\n- Add decorator support for `log.and_suppress` and `log.and_reraise` context\n managers\n- Suppress logging for null/empty log message templates\n\n\n0.2.0 (2018-10-03)\n------------------\n\nChanged default templates. In 0.1.0, the templates were:\n\n.. code:: python\n\n DEFAULT_TEMPLATES = {\n 'start': 'Start {label}',\n 'finish': 'Finish {label}',\n }\n\n\nThese defaults have been changed to:\n\n.. code:: python\n\n DEFAULT_TEMPLATES = {\n 'start': 'Enter {label}',\n 'finish': 'Exit {label}',\n 'function.start': 'Call `{label}({arguments})`',\n 'function.finish': 'Return from `{label}`',\n }\n\n0.1.0 (2018-10-03)\n------------------\n\n* First release on PyPI.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tonysyu/logquacious", "keywords": "logquacious", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "logquacious", "package_url": "https://pypi.org/project/logquacious/", "platform": "", "project_url": "https://pypi.org/project/logquacious/", "project_urls": { "Homepage": "https://github.com/tonysyu/logquacious" }, "release_url": "https://pypi.org/project/logquacious/0.5.0/", "requires_dist": [ "bumpversion; extra == 'dev'", "ipdb; extra == 'dev'", "ipython; extra == 'dev'", "twine; extra == 'dev'", "wheel; extra == 'dev'", "coverage; extra == 'dev'", "flake8; extra == 'dev'", "manuel; extra == 'dev'", "mock; extra == 'dev'", "pytest; extra == 'dev'", "pytest-cov; extra == 'dev'", "pytest-flake8; extra == 'dev'", "pytest-sugar; extra == 'dev'", "sphinx; extra == 'dev'", "sphinx-autobuild; extra == 'dev'", "sphinx-rtd-theme; extra == 'dev'", "sphinxcontrib-napoleon; extra == 'dev'", "sphinx; extra == 'docs'", "sphinx-autobuild; extra == 'docs'", "sphinx-rtd-theme; extra == 'docs'", "sphinxcontrib-napoleon; extra == 'docs'" ], "requires_python": "", "summary": "Logging utilities to help you over-communicate", "version": "0.5.0" }, "last_serial": 5230088, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2ce82d63a2e9094b414003bae9e73a13", "sha256": "00bc4beb4ec981204b7967d31399962fdf30ff4817df4b0708f8dd20bcbc1a91" }, "downloads": -1, "filename": "logquacious-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2ce82d63a2e9094b414003bae9e73a13", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10570, "upload_time": "2018-10-04T03:01:21", "url": "https://files.pythonhosted.org/packages/54/f3/99d5e1ab52453cb0fb7fce7c575d0f1b25511cc6b78e2918b3ac930d8ae8/logquacious-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f634da988285b3edb8a97be3f75c77f8", "sha256": "60f6e566c8682909f1be00a0d2122ddd59664529c4c58b41028557c981715222" }, "downloads": -1, "filename": "logquacious-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f634da988285b3edb8a97be3f75c77f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21382, "upload_time": "2018-10-04T03:01:22", "url": "https://files.pythonhosted.org/packages/31/d0/9ce059e8af7288c2b36ac635911e377c4c14a3a50442cabce0e9ac065597/logquacious-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "4f934d4205ff1af39199fc23df887476", "sha256": "e68450c6fdca74cf4aa45f8ee42e82ba841f5d323ac01bf0afb6c54008199e3c" }, "downloads": -1, "filename": "logquacious-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4f934d4205ff1af39199fc23df887476", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10946, "upload_time": "2018-10-04T04:05:12", "url": "https://files.pythonhosted.org/packages/58/2a/32a02371e5e3cb1f838e0296720ed6738bef6a116dcf564504f1453dadbf/logquacious-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a00c0d445c87772e250afb8a650607f1", "sha256": "bf628febdc2cd93d37503bcab76227d782abfadefb2e2785ecf1b9965fe30ddb" }, "downloads": -1, "filename": "logquacious-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a00c0d445c87772e250afb8a650607f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22279, "upload_time": "2018-10-04T04:05:13", "url": "https://files.pythonhosted.org/packages/c4/cd/180fa3baf6652b00b9596d48033383bbeaff1bb64c969046928b34252073/logquacious-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "a255abef0168f509d4190093439bf727", "sha256": "4786efb3c393fef2bbad30f068a70538b6d7e339c7911629e8ea22bc702ce8ad" }, "downloads": -1, "filename": "logquacious-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a255abef0168f509d4190093439bf727", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11353, "upload_time": "2018-10-06T02:02:52", "url": "https://files.pythonhosted.org/packages/8f/9d/c50901e012cb5d56ea4e1e32e1b6dad4cd33cc1a9156708d9940847e4339/logquacious-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cdc40a2189838df37c512ee206ecc1ef", "sha256": "e8d631b81216466fcc4898fc03eea74469b6ad1dbba6c412d0398156c503b183" }, "downloads": -1, "filename": "logquacious-0.3.0.tar.gz", "has_sig": false, "md5_digest": "cdc40a2189838df37c512ee206ecc1ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22763, "upload_time": "2018-10-06T02:02:53", "url": "https://files.pythonhosted.org/packages/e5/f8/ee068684b33cbfc7633c843bef3bd1d735fe42b669ab3be63464ac4268f0/logquacious-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "7263315c8b2a8ffe97456576e1ea7e98", "sha256": "17a696d458bc139a0183288c6be3ec45915ea9206a721e50fa048998d9a20387" }, "downloads": -1, "filename": "logquacious-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7263315c8b2a8ffe97456576e1ea7e98", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11530, "upload_time": "2018-10-06T02:45:30", "url": "https://files.pythonhosted.org/packages/0f/3c/b0b9d53dfb60faea990a1e16164b6f27b31a6da352801b8e25ebac18f1d2/logquacious-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d2cb04a1b2d665dd904a6e158247fb0d", "sha256": "1302a04dd72c468c7f59d2eb74044bcf963433dbbd0028f26794586e48b70bb9" }, "downloads": -1, "filename": "logquacious-0.4.0.tar.gz", "has_sig": false, "md5_digest": "d2cb04a1b2d665dd904a6e158247fb0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23007, "upload_time": "2018-10-06T02:45:31", "url": "https://files.pythonhosted.org/packages/19/86/cb2e47992568aaed0c187d02dfa2f06cc96986cd4b6e5030e7edf034c962/logquacious-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "02a9a884881c72cd38107fc08e3d5fa9", "sha256": "a31ad48746c1b2b6e1b80556436ca89fc9e86e445577de97219094c3486b12bf" }, "downloads": -1, "filename": "logquacious-0.5.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "02a9a884881c72cd38107fc08e3d5fa9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14239, "upload_time": "2019-05-05T23:55:31", "url": "https://files.pythonhosted.org/packages/60/82/f80dd0cee782b1feb63655d82f3d2c2b64fcbd5a2c5b16ff6281ecab13bd/logquacious-0.5.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "563b3cee41c97e8eed9d58865b987bbe", "sha256": "97142f4a4709d03bf37db67213f82ed70eb1d8dddb587cb06e60520924c5cce5" }, "downloads": -1, "filename": "logquacious-0.5.0.tar.gz", "has_sig": false, "md5_digest": "563b3cee41c97e8eed9d58865b987bbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25882, "upload_time": "2019-05-05T23:55:33", "url": "https://files.pythonhosted.org/packages/5d/86/e4b8f861fca5ad3a8da13f135dfb97d30d27b3c101563712bee79d54e06f/logquacious-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "02a9a884881c72cd38107fc08e3d5fa9", "sha256": "a31ad48746c1b2b6e1b80556436ca89fc9e86e445577de97219094c3486b12bf" }, "downloads": -1, "filename": "logquacious-0.5.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "02a9a884881c72cd38107fc08e3d5fa9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14239, "upload_time": "2019-05-05T23:55:31", "url": "https://files.pythonhosted.org/packages/60/82/f80dd0cee782b1feb63655d82f3d2c2b64fcbd5a2c5b16ff6281ecab13bd/logquacious-0.5.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "563b3cee41c97e8eed9d58865b987bbe", "sha256": "97142f4a4709d03bf37db67213f82ed70eb1d8dddb587cb06e60520924c5cce5" }, "downloads": -1, "filename": "logquacious-0.5.0.tar.gz", "has_sig": false, "md5_digest": "563b3cee41c97e8eed9d58865b987bbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25882, "upload_time": "2019-05-05T23:55:33", "url": "https://files.pythonhosted.org/packages/5d/86/e4b8f861fca5ad3a8da13f135dfb97d30d27b3c101563712bee79d54e06f/logquacious-0.5.0.tar.gz" } ] }