{ "info": { "author": "S\u00e9bastien Boisg\u00e9rault", "author_email": "Sebastien.Boisgerault@mines-paristech.fr", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Logging" ], "description": "\nPreamble\n--------------------------------------------------------------------------------\n\nLet's do this ! First, as expected:\n\n >>> import logfile\n\nThe `logfile` module outputs the log messages to `sys.stderr` by default;\nfor testing purposes, we redirect the logs to `sys.stdout`.\n\n >>> import sys\n >>> logfile.config.output = sys.stdout\n\nLogfile\n--------------------------------------------------------------------------------\n\nLogfiles are named files that also behave like integers:\n\n >>> import logfile\n >>> warning = logfile.warning\n >>> hasattr(warning, \"write\")\n True\n >>> warning.name == str(warning) == \"warning\"\n True\n >>>\n >>> int(warning)\n 0\n\nFive standard logfiles are defined:\n\n >>> names = \"critical error warning info debug\".split()\n >>> logfiles = [getattr(logfile, name) for name in names]\n >>> for lf in logfiles:\n ... format = \"{0:>8}: {1:>2}\".format \n ... print format(str(lf), int(lf))\n critical: -2\n error: -1\n warning: 0\n info: 1\n debug: 2\n\nThe logfile integer value measure the importance of the channel ; \nthe lower the number, the more important the messages sent to the logfile.\nConcretely, a message will *effectively* be logged only\nif it targets a logfile whose integer value is less or equal to\nthe current verbosity (`config.level`) ; the other messages are filtered out.\n\nThe default logfile verbosity is set to `warning` (or `0`), so only message \nthat target the `critical`, `error` and `warning` logfiles will logged.\n\nLet's check that in the default setting, information messages get lost:\n\n >>> info = logfile.info\n >>> logfile.config.level < info\n True\n >>> print >> info, \"testing info logfile ...\"\n\nAs expected, nothing gets printed. But if we set the logfile level to `info` \n(or higher), information messages don't get lost anymore:\n\n >>> logfile.config.level = info\n >>> print >> info, \"testing info logfile again\"\n testing info logfile again\n\n\nWriting into LogFiles\n--------------------------------------------------------------------------------\n\nMessages can be send to logfiles in two ways: either using the file \ninterface, as in:\n\n >>> print >> warning, \"I felt a disturbance in the Force.\"\n I felt a disturbance in the Force.\n\nor using the callable interface:\n\n >>> logfile.warning(\"I felt a disturbance in the Force.\")\n I felt a disturbance in the Force.\n\nThe former call is handy to quicky enable `logfile` support in a code full of \n`print` statements, but we advise you to adopt the second style to benefit\nfrom all features of `logfile`.\n\nMessage Variables \n--------------------------------------------------------------------------------\n\nThe message send to logfiles often depends on the value of local variables. \nTo simplify the definition of messages, we may refer to local variables\nin messages with the same curly brace syntax use by the \n[string.format method]. \nThe value of the variable will be automatically substituted into the message. \nFor example:\n\n >>> jedi = \"Luke\"\n >>> logfile.info(\"Use the Force, {jedi}.\")\n Use the Force, Luke.\n\n[string.format method]: http://docs.python.org/library/string.html#formatstrings\n\nStandard LogFile Hooks\n--------------------------------------------------------------------------------\n\nLogFile hooks are an easy way to automatically trigger an action when a message\nis sent to a logfile. Only the `error` and `critical` logfiles use hooks.\n\nA message send to `error` triggers an exception (so that you don't have to):\n\n >>> try:\n ... logfile.error(\"I felt a great disturbance in the Force.\\n\")\n ... except Exception as e:\n ... print repr(e)\n I felt a great disturbance in the Force.\n Exception('I felt a great disturbance in the Force.',)\n\nThe type of the exception defaults to `Exception` ;\nit may be controlled by the keyword argument `type`:\n\n >>> class ForceFluctuation(Exception):\n ... pass\n >>> try:\n ... message = \"I felt a great disturbance in the Force.\\n\"\n ... logfile.error(message, type=ForceFluctuation)\n ... except Exception as e:\n ... print repr(e)\n I felt a great disturbance in the Force.\n ForceFluctuation('I felt a great disturbance in the Force.',)\n\nA message send to `error` triggers a call to `sys.exit`:\n\n >>> try:\n ... logfile.critical(\"This is the end for you ... my former master.\\n\")\n ... except SystemExit as e:\n ... print repr(e)\n This is the end for you ... my former master.\n SystemExit('This is the end for you ... my former master.',)\n\nCustom Output Format\n--------------------------------------------------------------------------------\n\n >>> from datetime import datetime as _datetime\n >>> class mock_datetime(object):\n ... @staticmethod\n ... def now():\n ... return _datetime(2014, 1, 1, 12, 00, 00)\n >>> logfile.datetime.datetime = mock_datetime\n\n >>> def format(**kwargs):\n ... kwargs[\"date\"] = kwargs[\"date\"].strftime(\"%Y/%m/%d %H:%M:%S\")\n ... kwargs[\"logfile\"] = str(kwargs[\"logfile\"]).upper()\n ... return \"{date} | {logfile} from {tag} | {message}\".format(**kwargs)\n\n >>> logfile.config.format = format\n\n >>> def Yoda():\n ... info(\"Do. Or do not. There is no try.\")\n >>> Yoda()\n 2014/01/01 12:00:00 | INFO from Yoda | Do. Or do not. There is no try.\n\n", "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/boisgera/logfile", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "logfile", "package_url": "https://pypi.org/project/logfile/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/logfile/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/boisgera/logfile" }, "release_url": "https://pypi.org/project/logfile/1.2.0/", "requires_dist": null, "requires_python": null, "summary": "File-based logging library", "version": "1.2.0" }, "last_serial": 1312612, "releases": { "0.1.0-alpha.1": [ { "comment_text": "", "digests": { "md5": "26c415d1e636a31003ad60c36c798395", "sha256": "8981263943314e7b9f3114b8cf49454236fb8de49dc213a13be38f630e359cdc" }, "downloads": -1, "filename": "logfile-0.1.0-alpha.1.tar.gz", "has_sig": false, "md5_digest": "26c415d1e636a31003ad60c36c798395", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6907, "upload_time": "2013-11-20T11:04:19", "url": "https://files.pythonhosted.org/packages/b1/44/116c300484045491725c37a15072b2b107e1c7307dd4b98d9828e43f6a32/logfile-0.1.0-alpha.1.tar.gz" } ], "0.1.0-alpha.3": [ { "comment_text": "", "digests": { "md5": "7f178678d09cd1a24a80b1411cb5c113", "sha256": "3b00496bfa2c321f7eb1198e465d31b30c22699d6c469a7718d2df58f32be3f0" }, "downloads": -1, "filename": "logfile-0.1.0-alpha.3.tar.gz", "has_sig": false, "md5_digest": "7f178678d09cd1a24a80b1411cb5c113", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7119, "upload_time": "2013-12-05T15:16:50", "url": "https://files.pythonhosted.org/packages/09/62/c28d552bef9a1d0a55fb655a8fabe35860505c3ed0f883fab0d4d3992e3d/logfile-0.1.0-alpha.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ff3878ace4588e35877bc0f9d06c3e4a", "sha256": "28e241ee8dc89b5d0ca9b0b5223f0eb51a7cadd2c5089327ba1e79483e5b0b73" }, "downloads": -1, "filename": "logfile-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ff3878ace4588e35877bc0f9d06c3e4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7103, "upload_time": "2014-02-17T12:10:53", "url": "https://files.pythonhosted.org/packages/4e/09/da3d3226597dab2d8d42fcd4b73c09b0c8b5525898e9f73c1d1cfeb2d392/logfile-0.2.0.tar.gz" } ], "0.2.0-alpha": [ { "comment_text": "", "digests": { "md5": "32c851dd025c6909a6f7de7bede90bf6", "sha256": "cba331d7a52c1d1c92fad92f08a054cd0b056e6a949d4da2f0948947ba26f852" }, "downloads": -1, "filename": "logfile-0.2.0-alpha.tar.gz", "has_sig": false, "md5_digest": "32c851dd025c6909a6f7de7bede90bf6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7111, "upload_time": "2014-02-17T08:06:47", "url": "https://files.pythonhosted.org/packages/c8/a0/ce704075932b13dd93c271229f18b392c5a450b0ba891235be4816b2cf4b/logfile-0.2.0-alpha.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "00623a875d4466482678c53d24bea23a", "sha256": "9729003f8b69f34c8509cdd0621aca03b7c5d066394f2ac90ec8338bc2c52b52" }, "downloads": -1, "filename": "logfile-0.2.1.tar.gz", "has_sig": false, "md5_digest": "00623a875d4466482678c53d24bea23a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7098, "upload_time": "2014-02-17T15:27:46", "url": "https://files.pythonhosted.org/packages/51/0e/216290058335c6e8f229585c062ca2c5177af2eb070ed897b4e5e3382bfb/logfile-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "02aed796ad9060c6d5db0fe1c1ce2275", "sha256": "d762e466d156bd8390d7cd282e37a224a943679131026ffe92e0a4ebf3607449" }, "downloads": -1, "filename": "logfile-0.2.2.tar.gz", "has_sig": false, "md5_digest": "02aed796ad9060c6d5db0fe1c1ce2275", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7317, "upload_time": "2014-03-17T13:09:56", "url": "https://files.pythonhosted.org/packages/bb/8d/29de62b6cc7e9a6bc56f5d088805510c64c5c478a2864e4020832df7d5a7/logfile-0.2.2.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "a23dacd9b7d4c40fb0896e6f8bec1f32", "sha256": "c09d98541f4f9e45c8be542e8f60a245784f4c51d8af5fe55efa3477a544fb94" }, "downloads": -1, "filename": "logfile-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a23dacd9b7d4c40fb0896e6f8bec1f32", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541089, "upload_time": "2014-11-03T16:00:12", "url": "https://files.pythonhosted.org/packages/9b/d1/65402a177ec1ad87507a125b4c3f1ccfd1f792ab70e654725506e211d501/logfile-1.0.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "e952154f5c384acef8d4a881665a715a", "sha256": "da945c581aed5509eaa1dfed530eb213a350a3a4d4658098e9c95c74d5c07bc3" }, "downloads": -1, "filename": "logfile-1.1.1.tar.gz", "has_sig": false, "md5_digest": "e952154f5c384acef8d4a881665a715a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541054, "upload_time": "2014-11-04T13:29:54", "url": "https://files.pythonhosted.org/packages/b9/95/63706742bce27c086cfc3b2861eed8f580a4117fcef4158ac3c85bb85111/logfile-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "4693cc49d9508c7561f9c0125a0988ae", "sha256": "77d2214a13ce21fb51319e2b2fb15a36d0682aaa54034a955c4d54bc2d8f4a20" }, "downloads": -1, "filename": "logfile-1.1.2.tar.gz", "has_sig": false, "md5_digest": "4693cc49d9508c7561f9c0125a0988ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541215, "upload_time": "2014-11-04T15:32:16", "url": "https://files.pythonhosted.org/packages/a5/58/df04eb43b26d66aa85c4b2d8e6ee89d26afb944dcb485d9622245e1e63ce/logfile-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "fd2c6b4868d143448d55159ecdd32512", "sha256": "695e3996bf40e819575a9b6bb9668710af8a97418c271c6f128892dea06e7ecf" }, "downloads": -1, "filename": "logfile-1.1.3.tar.gz", "has_sig": false, "md5_digest": "fd2c6b4868d143448d55159ecdd32512", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541217, "upload_time": "2014-11-05T09:12:34", "url": "https://files.pythonhosted.org/packages/07/a7/5dde4dee828ddab88728a1600032711529b7a034a74107b31b2e425f3184/logfile-1.1.3.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "a49d68ce131171b2cc5eb5a7a4e26ef0", "sha256": "a5c83aca547a455246c030fc20bb7079e768bebddbb0d60572eba6df8d604c41" }, "downloads": -1, "filename": "logfile-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a49d68ce131171b2cc5eb5a7a4e26ef0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541131, "upload_time": "2014-11-19T10:59:31", "url": "https://files.pythonhosted.org/packages/27/4e/e40eb384e4673332fe560903b62199d9cbbd8be3e3934241d8520f259f8c/logfile-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a49d68ce131171b2cc5eb5a7a4e26ef0", "sha256": "a5c83aca547a455246c030fc20bb7079e768bebddbb0d60572eba6df8d604c41" }, "downloads": -1, "filename": "logfile-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a49d68ce131171b2cc5eb5a7a4e26ef0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 541131, "upload_time": "2014-11-19T10:59:31", "url": "https://files.pythonhosted.org/packages/27/4e/e40eb384e4673332fe560903b62199d9cbbd8be3e3934241d8520f259f8c/logfile-1.2.0.tar.gz" } ] }