{ "info": { "author": "Xurui Yan", "author_email": "yxr1993@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "License :: OSI Approved :: MIT License", "Operating System :: Unix", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "logdogs\n=======\n\n.. image:: https://img.shields.io/travis/yanxurui/logdogs/master.svg\n :target: https://travis-ci.org/yanxurui/logdogs\n\n.. image:: https://img.shields.io/pypi/v/logdogs.svg\n :target: https://pypi.org/project/logdogs\n\n.. image:: https://img.shields.io/pypi/pyversions/logdogs.svg\n :target: https://pypi.org/project/logdogs\n\n.. image:: https://img.shields.io/pypi/status/logdogs.svg\n :target: https://pypi.org/project/logdogs\n\n\nA daemon to monitor keywords in any log files specified by glob pattern.\n\nIn the background log files are checked periodically by dogs and user\ndefined handlers are called when error lines are detected according the\nkeyword regex.\n\nfeatures\n--------\n\n- glob path\n- regex keywords\n- compatible with logrotate\n- custmize handler function or callable object\n- log files don't have to exist before watch\n- a dog can watch multiple logs and a log can be watched by multiple\n dogs\n\nusage\n-----\n\ninstall::\n\n pip install logdogs\n\nstart::\n\n logdogs -c conf.py\n\nstop::\n\n kill \n\npid file will be removed automatically.\n\nconf.py is your config file which contains upper case module variables\nas configuration. Here is an example:\n\n.. code:: python\n\n import os\n import logging\n\n LOG_FILE = 'logdogs.log'\n LOG_LEVEL = 'INFO'\n # you can even call basicConfig to customize the log instead\n\n INTEVAL = 10 # seconds\n\n DAEMONIZE = True\n DIR = os.path.abspath('.')\n PID_FILE = 'logdogs.pid'\n STDOUT = 'logdogs.out'\n STDERR = 'logdogs.err'\n # the above 4 configurations only work when DAEMONIZE is True\n\n logger = logging.getLogger(__name__)\n\n class MyHandler(object):\n def __init__(self):\n self.count = 0\n\n def __call__(self, file, lines):\n self.count += 1\n logger.info('...')\n # Do whatever you want here...\n\n DOGS = {\n \"test\": {\n \"paths\": [\"a.log\", \"b.log\"],\n \"handler\": MyHandler(),\n \"includes\": [r\"wrong\"],\n \"excludes\": [r\"nothing\"]\n },\n \"glob\": {\n \"paths\": [\"**/*.log\"],\n \"handler\": MyHandler(),\n \"includes\": [r\"(?!)wrong\"],\n }\n }\n\nIn this case, logdogs will run as a daemon process in current directory\nand check log files every 10 seconds. a.log and b.log will be watched\nboth by dog test and glob. When a line containing ``wrong`` but not\n``nothing`` is written to a.log, both dogs' handler will be called.\n\nThe effective variables in config file are described as below.\n\nconfig\n------\n\nDOGS\n~~~~\n\nA Dog consists of:\n\n1. a group of log files specified by glob pattern\n2. a filter defined by includes and excludes\n3. a handler function or a callable object\n\nDOG is a dict in the form of ``{name: attribute}`` where ``name`` is not\nimportant and ``attribute`` is a dict containing the following keys:\n\nhandler\n^^^^^^^\n\na handler is a function which has the following signature::\n\n def handler(file, lines):\n \"\"\"\n file is the absolute path of the log file.\n lines is a list of the lines includes newline characters(\\n)\n \"\"\"\n pass\n\nthe default handler is a callable object of::\n\n class Handler(object):\n \"\"\"\n default handler for log event\n \"\"\"\n def __call__(self, file, lines):\n print(lines)\n\nIt's up to you to deal with the log line in this handler such as\nmailing, send to wechat and etc.\n\nincludes & excludes\n^^^^^^^^^^^^^^^^^^^\n\nThey are regular expressions and both are optional. The handler is\ncalled if any regex in includes is found in the line and any regex in\nexcludes is not found in the line. That is to say, ``or`` logic is\napplied in the includes and ``and`` logic is applied in the excludes.\n\npath\n^^^^\n\npath is a list, it supports the following forms:\n\n1. single file: ``['/var/logs/a.log']``\n2. multiple files: ``['/var/logs/a.log', '/var/logs/b.log']``\n3. glob pattern: ``['/var/logs/*.log']``\n4. recursive glob (similar as globstar on bash): ``['/var/logs/**/*.log']``\n\n- In the last 2 cases, a log file is not required to exist when monitor\n starts\n- The same log file can overlap in multiple dog block\n\nINTEVAL\n~~~~~~~\n\nseconds for sleep between checks\n\nlog\n~~~\n\n- LOG_FILE: specify log file. logs are printed to stdout if not\n specified\n- LOG_LEVEL(WARNING): which log level to use\n\ndaemonize\n~~~~~~~~~\n\n- DAEMONIZE(False): whether to start a daemon process running in the\n backgroup, **the following configs only take effect when DAEMONIZE is\n True**\n- DIR: set the working directory, **default is /**\n- PID_FILE: pid file path\n- STDOUT: where to redirect stdout(print exception traceback for\n example)\n- STDERR: where to redirect sterr\n\nDevelopment\n-----------\n\n::\n\n python setup.py develop\n\ntest\n~~~~\n\n::\n\n python -m unittest -v test_function.TestFunction\n\ntodo\n~~~~\n\n- more handlers\n- threading\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yanxurui/logdogs", "keywords": "log monitor", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "logdogs", "package_url": "https://pypi.org/project/logdogs/", "platform": "Linux", "project_url": "https://pypi.org/project/logdogs/", "project_urls": { "Homepage": "https://github.com/yanxurui/logdogs" }, "release_url": "https://pypi.org/project/logdogs/0.2/", "requires_dist": null, "requires_python": "", "summary": "A daemon to monitor keywords in any log files specified by glob pattern", "version": "0.2" }, "last_serial": 3308944, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "aa9bc0b92f78cacf0f37c8f9db26b9ae", "sha256": "5f6a65fa1be5025f6941d413092cfbe43a5237461143f0ceb87ef1c79f4d22cf" }, "downloads": -1, "filename": "logdogs-0.0.1.tar.gz", "has_sig": false, "md5_digest": "aa9bc0b92f78cacf0f37c8f9db26b9ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5224, "upload_time": "2017-11-03T13:03:22", "url": "https://files.pythonhosted.org/packages/06/f7/7d8f98bdbc165c234c63451a7c6e2998fb42476ae898d7d43326eac167bf/logdogs-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "adf4204ca8490f5e39c7c205a7d5f776", "sha256": "2bdf98ba1866d4990bf2e937bf81156a20e1d50cfa4713b0c21349d9727de76a" }, "downloads": -1, "filename": "logdogs-0.1.0.tar.gz", "has_sig": false, "md5_digest": "adf4204ca8490f5e39c7c205a7d5f776", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6591, "upload_time": "2017-11-03T16:32:59", "url": "https://files.pythonhosted.org/packages/1a/99/db33daea8835759ba5a54fd98212aa9127a96e482ac9b0876e1a20b04290/logdogs-0.1.0.tar.gz" } ], "0.1.0b1": [ { "comment_text": "", "digests": { "md5": "3fbd461a9a623a7c90756111c60f97eb", "sha256": "4050cf5e54abe4f3f8d2f7097613b529963c6d515d99f2745491f97879ab4a4f" }, "downloads": -1, "filename": "logdogs-0.1.0b1.tar.gz", "has_sig": false, "md5_digest": "3fbd461a9a623a7c90756111c60f97eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6770, "upload_time": "2017-11-03T16:41:44", "url": "https://files.pythonhosted.org/packages/34/bc/9edba5be02dd7812bf31e0d129cb1ef2628e123e7992acdffe9458dfbda1/logdogs-0.1.0b1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "4871d01d85f27088f2d00834487688e8", "sha256": "8d1c0d8d6f4ee7157d3aa75f83dc83f91bfee19a9c178bdba2598404fd38b7b7" }, "downloads": -1, "filename": "logdogs-0.2.tar.gz", "has_sig": false, "md5_digest": "4871d01d85f27088f2d00834487688e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6973, "upload_time": "2017-11-04T13:08:57", "url": "https://files.pythonhosted.org/packages/0b/a1/cb3a358f3b571bd5a5d3a62daf19cd3fb3940bbd6b38d16622c4172eaac4/logdogs-0.2.tar.gz" } ], "0.2rc1": [ { "comment_text": "", "digests": { "md5": "51716906f43afbf28b5b35157ff64a0b", "sha256": "f7d81da7a28d9328ae53b394dad44c7772722e946d092bf48a9549f38fb8d72d" }, "downloads": -1, "filename": "logdogs-0.2rc1.tar.gz", "has_sig": false, "md5_digest": "51716906f43afbf28b5b35157ff64a0b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6841, "upload_time": "2017-11-04T03:36:52", "url": "https://files.pythonhosted.org/packages/05/c2/4496d85d97d6d15908d8a863850983581d8e9de6ab73d63c9338ea3da850/logdogs-0.2rc1.tar.gz" } ], "0.2rc2": [ { "comment_text": "", "digests": { "md5": "dba3c89d30d214799eb21dd15506c3ca", "sha256": "1370fdf346a597a377b382a6d87eaf63eac4948659a8979316f2606dade9b176" }, "downloads": -1, "filename": "logdogs-0.2rc2.tar.gz", "has_sig": false, "md5_digest": "dba3c89d30d214799eb21dd15506c3ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6967, "upload_time": "2017-11-04T11:28:02", "url": "https://files.pythonhosted.org/packages/1c/a4/a3ba422c0933e3a8978f04455b67c1e0a9252b6d21d3fa75434f8a0cdfba/logdogs-0.2rc2.tar.gz" } ], "0.3b1": [ { "comment_text": "", "digests": { "md5": "a88d6a766338c1cc0d56b9a3346697fe", "sha256": "4c835d1c2b3de7e4278bb53d11aeda2cf2d0a9b4a01c974de2e6d65564d51771" }, "downloads": -1, "filename": "logdogs-0.3b1.tar.gz", "has_sig": false, "md5_digest": "a88d6a766338c1cc0d56b9a3346697fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5954, "upload_time": "2017-11-04T16:06:29", "url": "https://files.pythonhosted.org/packages/48/86/86b47831222ebab55381aa17ee89ad13b6c6425cddd094e38d5cfdbfca36/logdogs-0.3b1.tar.gz" } ], "0.3rc1": [ { "comment_text": "", "digests": { "md5": "c745d50b17960820d8095a8da7e56825", "sha256": "ea66f32a9a8d91e131cd702c984c2f78cc6c7389eddfcd41e340719150194b7e" }, "downloads": -1, "filename": "logdogs-0.3rc1.tar.gz", "has_sig": false, "md5_digest": "c745d50b17960820d8095a8da7e56825", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6500, "upload_time": "2017-11-06T09:51:27", "url": "https://files.pythonhosted.org/packages/c7/d6/e69b8cee249e31ea0a478176f633ff99b048c8056221e12bc5e4b4ea0fb5/logdogs-0.3rc1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4871d01d85f27088f2d00834487688e8", "sha256": "8d1c0d8d6f4ee7157d3aa75f83dc83f91bfee19a9c178bdba2598404fd38b7b7" }, "downloads": -1, "filename": "logdogs-0.2.tar.gz", "has_sig": false, "md5_digest": "4871d01d85f27088f2d00834487688e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6973, "upload_time": "2017-11-04T13:08:57", "url": "https://files.pythonhosted.org/packages/0b/a1/cb3a358f3b571bd5a5d3a62daf19cd3fb3940bbd6b38d16622c4172eaac4/logdogs-0.2.tar.gz" } ] }