{ "info": { "author": "fsjohnhuang", "author_email": "fsjohnhuang@hotmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "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", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation", "Topic :: Software Development :: Libraries" ], "description": "# oh-my-logging\nAn extension for logging module.\n\n# Install\n```\npip install oh_my_logging\n```\n\n# Usage\n## Decorators\n### logger\n\nInject logger object to function as the last parameter.\n```\nfrom oh_my_logging.decorators import logger\n\n@logger\ndef myprint(message, logger):\n logger.debug(message)\n logger.info(message)\n logger.warn(message)\n logger.error(message)\n \nmyprint('hello')\n```\n\n### log_args\n\nLog arguments of function.\n```\nfrom oh_my_logging.decorators import log_args\n\n@log_args\ndef sum(a, b):\n return a + b\n \nsum(1,2) # echo 'params: a=1, b=2'\n```\n\n### log_returnings\n\nLog retuning value of function.\n```\nfrom oh_my_logging.decorators import log_returnings\n\n@log_returnings\ndef sum(a, b):\n return a + b\n \nsum(1,2) # echo 'returning: 1'\n```\n\n### log_stat\n\nCount the execution time cost of specific function.\n```\nfrom oh_my_logging.decorators import log_stat\n\n@log_stat\ndef sum(a, b):\n return a + b\n \nsum(1,2) # echo statistic: 1.2ms'\n```\n\n### log_error\n\nLog exception info then raise exception again, or catch then ignore specific exceptions.\n```\nfrom oh_my_logging.decorators import log_error\n\n# Log then raise exception again.\n@log_error\ndef myfile(name):\n raise FileNotFoundException(name)\n\nmyfile('123')\n\n# Log then catch then ignore FileNotFoundException.\n@log_error(ignore_errors=(FileNotFoundException,))\ndef myfile2(name):\n raise FileNotFoundException(name)\n \nmyfile2('123')\n```\n\n### log\n\nSuper decorator which contains funtionalities of decorators all above. If you want to log two or more information, use this decorator instead suggested.\n```\nfrom oh_my_logging.decorators import log\n\n@log(log.ARGS, \n log.RETURNING, \n log.STAT, \n {'target': log.ERROR, \n 'ignore_errors': (FileNotFoundException,)})\ndef myfile(name):\n raise FileNotFoundException(name)\n\nmyfile('123')\n```\n\n## Logging Configuration\n### Default Configuration\nThe default logging configuration stored in `$PWD/logging.ini`.\n\n### JSON/YAML Configuration\n```\nfrom oh_my_logging.builders import LoggerBuilderFactory\n\n# JSON\nLoggerBuilderFactory('/path/to/logging.js')\n\nLoggerBuilderFactory.unsafe_clear()\nLoggerBuilderFactory('/path/to/logging.json')\n\n# YAML\nLoggerBuilderFactory.unsafe_clear()\nLoggerBuilderFactory('/path/to/logging.yml)\n\nLoggerBuilderFactory.unsafe_clear()\nLoggerBuilderFactory('/path/to/logging.yaml)\n```\n\n### Dict Configuration\n```\nfrom oh_my_logging.builders import LoggerBuilderFactory\n\ndictConfig = {\n 'version': 1,\n 'root': {\n 'level': 'DEBUG',\n 'handlers': ['memory'],\n },\n 'handlers': {\n 'memory': {\n 'class': 'oh_my_logging.handlers.MemoryHandler',\n 'formatter': 'default',\n },\n },\n 'formatters': {\n 'default': {\n 'format': '%(message)s',\n },\n },\n}\nLoggerBuilderFactory(dictConfig)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fsjohnhuang/oh-my-logging", "keywords": "", "license": "MIT", "maintainer": "fsjohnhuang", "maintainer_email": "fsjohnhuang@hotmail.com", "name": "oh-my-logging", "package_url": "https://pypi.org/project/oh-my-logging/", "platform": "any", "project_url": "https://pypi.org/project/oh-my-logging/", "project_urls": { "Homepage": "https://github.com/fsjohnhuang/oh-my-logging" }, "release_url": "https://pypi.org/project/oh-my-logging/0.1.1/", "requires_dist": null, "requires_python": ">=2.7", "summary": "Enhancement for logging.", "version": "0.1.1" }, "last_serial": 5550069, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "56aec1bb7884a6ad3b81d9841555fe1a", "sha256": "3e4f45fa7994f2ebfb4f7f6192378ff9f7a710dc3bfcc0b8bfabbfe55a5027a8" }, "downloads": -1, "filename": "oh-my-logging-0.1.0.1.tar.gz", "has_sig": false, "md5_digest": "56aec1bb7884a6ad3b81d9841555fe1a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 4100, "upload_time": "2019-07-11T10:19:25", "url": "https://files.pythonhosted.org/packages/7d/aa/ea4086031d6a759793b5622c3d5a2fd5755ebb3b746982b809a901c44d6f/oh-my-logging-0.1.0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b750b96ee658d06edd76b17853ada4e8", "sha256": "51943e61a79fb1d72cc3986e259e9119865385325db4c2e0fc2d3bce8ddc854d" }, "downloads": -1, "filename": "oh-my-logging-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b750b96ee658d06edd76b17853ada4e8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 7076, "upload_time": "2019-07-18T09:44:05", "url": "https://files.pythonhosted.org/packages/6c/b8/34464d030faff3ca08b8de86171255c21e18c6690197d5df48da34afebde/oh-my-logging-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b750b96ee658d06edd76b17853ada4e8", "sha256": "51943e61a79fb1d72cc3986e259e9119865385325db4c2e0fc2d3bce8ddc854d" }, "downloads": -1, "filename": "oh-my-logging-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b750b96ee658d06edd76b17853ada4e8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 7076, "upload_time": "2019-07-18T09:44:05", "url": "https://files.pythonhosted.org/packages/6c/b8/34464d030faff3ca08b8de86171255c21e18c6690197d5df48da34afebde/oh-my-logging-0.1.1.tar.gz" } ] }