{ "info": { "author": "yorks", "author_email": "stuyorks@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Logging" ], "description": "Overview\n========\n\nThis module provides an additional log handler for Python\u2019s standard\nlogging package (PEP 282). This handler will write log events to log\nfile which is rotated at a certain time(day, hour, min) and multiple\nprocesses supported.\n\n\u8fd9\u4e2a\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e2a Python logging handler \u7c7b\u3002\u5b83\u4f1a\u6839\u636e\u914d\u7f6e\u6309\u65f6\u95f4\u6765\n\u8f6e\u8f6c\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u4e14\u652f\u6301\u591a\u8fdb\u7a0b\n\nDetails\n=======\n\nThe `MultProcTimedRotatingFileHandler` class is a drop-in replacement\nfor Python\u2019s standard log handler `RotatingFileHandler`. This module\nuses file locking so that multiple processes can concurrently log to a\nsingle file without dropping or clobbering log events. This module\nprovides a file rotation scheme like with `RotatingFileHanler`. Extra\ncare is taken to ensure that logs can be safely rotated before the\nrotation process is started.\n\nThis class ratating file at an exact time, such as every day(23:59:59)\nor every hour(xx:59:59) and so on.\n\nIf you have multiple instances of a script (or multiple scripts) all\nrunning at the same time and writing to the same log file, then *all* of\nthe scripts should be using this class.\n\nThis class require `portalocker` to deal with file locking. Please be\naware that portalocker only supports Unix (posix) an NT platforms at\nthis time, and therefore this package only supports those platforms as\nwell. But, only tested on Linux.\n\n\u57fa\u4e8e\u6807\u51c6\u7684 `RotatingFileHandler` \u7c7b\u5f00\u53d1\uff0c\u652f\u6301\u591a\u7ebf\u7a0b\uff0c\u591a\u8fdb\u7a0b\uff0c\n\u8f6e\u8f6c\u65b9\u5f0f\u662f\u6309\u7167\u65f6\u95f4, \u6bcf\u5929/\u6bcf\u5c0f\u65f6/\u6bcf\u5206\u949f\n\u4e0d\u4f9d\u8d56\u4e8e\u8fdb\u7a0b\u7684\u542f\u52a8\u65f6\u95f4\uff0c\u800c\u662f\u6839\u636e\u7cfb\u7edf\u65f6\u95f4 \u8fdb\u884c\u8f6e\u8f6c.\n\n\u5982\u679c\u6709\u591a\u4e2a\u811a\u672c\u6216\u8005\u5b9e\u4f8b\u90fd\u9700\u8981\u6253\u65e5\u5fd7\u5230\u540c\u4e00\u4e2a\u6587\u4ef6\uff0c\u8bf7\u4e00\u5b9a\u90fd\u8981\u7528\u8fd9\u4e2a\u7c7b\n`MultProcTimedRotatingFileHandler`, \u56e0\u4e3a\u5b83\u662f\u57fa\u4e8e\u6587\u4ef6\u9501\u7684.\n\n\u8fd9\u4e2a\u7c7b\u4f7f\u7528\u4e86 `portalocker` \u53bb\u5904\u7406\u591a\u8fdb\u7a0b\u4e4b\u95f4\u7684\u6587\u4ef6\u9501\uff0c\u6240\u4ee5\u5b83\u53ea\u652f\u6301\n\\*nix \u8ddf NT \u7cfb\u7edf\uff0c \u4f46\u662f\u6211\u53ea\u6d4b\u8bd5\u4e86\u5728 Linux \u4e0b\u9762\u4f7f\u7528\u3002\n\n\n\nWhy\n===\n\nThis class fork from `TimedRotatingFileHandler` and\n`ConcurrentLogHandler`. For `TimedRotatingFileHandler` issues:\n\n1. thread safe but not process safe\n2. rotating time is accumulate, this means it deponding the process when\n to start up.\n\n`ConcurrentLogHandler` is good, but it only rotating by the logfile\nsize.\n\n\u8fd9\u4e2a\u7c7b\u5176\u5b9e\u662f\u53c2\u8003\u4e86\n`TimedRotatingFileHandler`\\ \uff0c\\ `ConcurrentLogHandler`\n\u8fd9\u4e24\u4e2ahandler, \u4e3a\u4ec0\u4e48\u8981\u5199\u8fd9\u4e2a\u5462\uff1f\u4e3b\u8981\u662f\u4e0a\u9762\u63d0\u5230\u7684\u8fd9\u4e24\u4e2a\u90fd\u6709\u4e00\u4e9b\u5c0f\u95ee\u9898\u3002\n\n`TimedRotatingFileHandler`:\n\n1. \u867d\u7136\u662f\u7ebf\u7a0b\u5b89\u5168\uff0c\u4f46\u662f\u5e76\u4e0d\u652f\u6301\u591a\u8fdb\u7a0b\n2. \u8f6e\u8f6c\u7684\u65f6\u95f4\u662f\u4f9d\u8d56\u4e8e\u8fdb\u7a0b\u7684\u542f\u52a8\u65f6\u95f4\uff0c\u6240\u4ee5\u4f1a\u51fa\u73b0\u8f6e\u8f6c\u70b9\u5e76\u4e0d\u662f\u5e38\u89c4\u768459s.\n\n`ConcurrentLogHandler` \u5982\u679c\u53ea\u662f\u5b9e\u73b0\u4e86\u6839\u636e\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u6765\u8f6e\u8f6c,\n\u672a\u63d0\u4f9b\u6309\u65f6\u95f4\u7684.\n\nInstallation\n============\n\nUse the following command to install this package:\n\n::\n\n pip install mpfhandler\n\nIf you are installing from source, you can use:\n\n::\n\n python setup.py install\n\nOr wget the single file to your python sys.path:\n\n::\n\n wget https://github.com/yorks/mpfhandler/raw/master/src/mpfhandler.py -O\\\n /usr/lib/python2.6/site-packages/mpfhandler.py\n\n\nExamples\n========\n\nSimple Example\n--------------\n\nHere is a example demonstrating how to use this module directly\n\n.. code:: python\n\n\n from logging import getLogger, INFO\n from mpfhandler import MultProcTimedRotatingFileHandler\n import os\n \n log = getLogger()\n # Use an absolute path to prevent file rotation trouble.\n logfile = os.path.abspath(\"mylogfile.log\")\n # Rotate log every hour\n rotateHandler = MultProcTimedRotatingFileHandler(logfile, when='h')\n log.addHandler(rotateHandler)\n log.setLevel(INFO)\n\n log.info(\"Here is a very exciting log message, just for you\")\n\nDjango Example\n--------------\n\n.. code:: python\n\n # settings.py\n LOGGING={\n #...\n 'handlers':{\n 'custom_mpf_rotate':{\n 'level': 'DEBUG',\n 'class': 'mpfhandler.MultProcTimedRotatingFileHandler',\n 'filename': os.path.join(BASE_DIR, 'logs/custom_mptf.log'),\n 'when' : 'D', # day, or H for hour\n #'interval' : 1, # TODO\n #'debug' : False, # handler own log\n 'formatter': 'verbose'\n },\n },\n 'loggers':{\n ...\n 'customapp': {\n 'handlers': ['console', 'custom_mpf_rotate'],\n 'level': 'DEBUG',\n 'propagate': False,\n },\n #...\n }\n\n }\n\n # app/view.py\n import logging\n log=logging.getLogger(__name__)\n log.info('Here is a very exciting log message, just for you')\n\nAttention\n=========\n\n1. interval, backupCount options is not working!\n2. $logpath.lock is the lock file to handle multiple processes, donot\n delete it.\n3. There is no stress-testing has been done, if it slow down for logging\n it might be the lock issue.\n\n\u6ce8\u610f\n====\n\n1. `interval`, `backupCount`\n \u53c2\u6570\u6682\u4e0d\u652f\u6301\uff0c\u8fd9\u4e5f\u5c31\u662f\u8bf4\uff0c\u65e5\u5fd7\u7684\u538b\u7f29\u6e05\u7406\u60a8\u9700\u8981\u989d\u5916\u5904\u7406\u3002\n2. `$logpath.lock` \u8fd9\u4e2a\u6587\u4ef6\u8bf7\u4e0d\u8981\u5220\u9664\uff0c\u662f\u7528\u6765\u5904\u7406\u6587\u4ef6\u9501\u7684\u3002\n3. \u8fd8\u6ca1\u7ecf\u8fc7\u538b\u529b\u6d4b\u8bd5\uff0c\u5982\u679c\u62c5\u5fc3\u4f1a\u6258\u6162\u60a8\u7684\u7a0b\u5e8f\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u6587\u4ef6\u9501\u5f15\u8d77.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/yorks/mpfhandler/releases/tag/0.0.1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yorks/mpfhandler", "keywords": "logging,linux,unix,rotate,portalocker,django,mutiple processes", "license": "http://www.apache.org/licenses/LICENSE-2.0", "maintainer": null, "maintainer_email": null, "name": "mpfhandler", "package_url": "https://pypi.org/project/mpfhandler/", "platform": "nt,posix", "project_url": "https://pypi.org/project/mpfhandler/", "project_urls": { "Download": "https://github.com/yorks/mpfhandler/releases/tag/0.0.1", "Homepage": "https://github.com/yorks/mpfhandler" }, "release_url": "https://pypi.org/project/mpfhandler/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "a timed rotate logging file handler, support multiple processes (base logging.RotatingFileHandler, portalocker)", "version": "0.0.1" }, "last_serial": 1711235, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1bbbdb1caffee9743e24a35aa78f4a50", "sha256": "e02b1fbe79b2cafcc1d0695520a885754c74f17cbe1407af9cc338ede0968da7" }, "downloads": -1, "filename": "mpfhandler-0.0.1.zip", "has_sig": false, "md5_digest": "1bbbdb1caffee9743e24a35aa78f4a50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14365, "upload_time": "2015-09-07T03:19:15", "url": "https://files.pythonhosted.org/packages/ca/22/28e537673cdd23cc49e58cb59cebb681db8011b490cfbc10c430399889b5/mpfhandler-0.0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1bbbdb1caffee9743e24a35aa78f4a50", "sha256": "e02b1fbe79b2cafcc1d0695520a885754c74f17cbe1407af9cc338ede0968da7" }, "downloads": -1, "filename": "mpfhandler-0.0.1.zip", "has_sig": false, "md5_digest": "1bbbdb1caffee9743e24a35aa78f4a50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14365, "upload_time": "2015-09-07T03:19:15", "url": "https://files.pythonhosted.org/packages/ca/22/28e537673cdd23cc49e58cb59cebb681db8011b490cfbc10c430399889b5/mpfhandler-0.0.1.zip" } ] }