{ "info": { "author": "sashgorokhov", "author_email": "sashgorokhov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Debuggers", "Topic :: System :: Logging" ], "description": "python-telegram-handler\n***********************\n\n.. image:: https://img.shields.io/pypi/status/python-telegram-handler.svg\n :target: https://github.com/sashgorokhov/python-telegram-handler\n\n.. image:: https://img.shields.io/pypi/pyversions/python-telegram-handler.svg\n :target: https://pypi.python.org/pypi/python-telegram-handler\n\n.. image:: https://badge.fury.io/py/python-telegram-handler.svg \n :target: https://badge.fury.io/py/python-telegram-handler \n\n.. image:: https://travis-ci.org/sashgorokhov/python-telegram-handler.svg?branch=master \n :target: https://travis-ci.org/sashgorokhov/python-telegram-handler \n\n.. image:: https://codecov.io/github/sashgorokhov/python-telegram-handler/coverage.svg?branch=master \n :target: https://codecov.io/github/sashgorokhov/python-telegram-handler?branch=master \n\n.. image:: https://codeclimate.com/github/sashgorokhov/python-telegram-handler/badges/gpa.svg\n :target: https://codeclimate.com/github/sashgorokhov/python-telegram-handler\n :alt: Code Climate\n\n.. image:: https://img.shields.io/github/license/sashgorokhov/python-telegram-handler.svg \n :target: https://raw.githubusercontent.com/sashgorokhov/python-telegram-handler/master/LICENSE \n\n\nA python logging handler that sends logs via Telegram Bot Api\n\nInstallation\n============\n\nVia pip:\n\n.. code-block:: shell\n\n pip install python-telegram-handler\n\nUsage\n=====\n\nRegister a new telegram bot and obtain a ``authentication token``. (Instructions here https://core.telegram.org/bots#3-how-do-i-create-a-bot)\n\nAfter that, you must obtain a ``chat_id``. You can do that using included simple script. Start a new conversation with newly created bot, write something to it (it is important to initiate conversation first).\n\nAlso, there is an ability for handler to automatically retrieve ``chat_id``. This will be done on handler initialization. But you still have to start a conversation with bot. Be aware: if program stops, server restarts, or something else will happen - handler will try to retrieve chat id from telegram, and may fail, if it will not find a NEW message from you. So i recommend you to use a script below for obtaining chat id. \n\nThen run a command:\n\n.. code-block:: shell\n\n python -m telegram_handler \n \nIf all went ok, a ``chat_id`` will be printed to stdout.\n\nUsing ``token`` and ``chat_id``, configure log handler in your desired way.\nFor example, using dictConfig:\n\n.. code-block:: python\n\n {\n 'version': 1,\n 'handlers': {\n 'telegram': {\n 'class': 'telegram_handler.TelegramHandler',\n 'token': 'your token',\n 'chat_id': 'chat id'\n }\n },\n 'loggers': {\n 'my_logger': {\n 'handlers': ['telegram'],\n 'level': 'DEBUG'\n }\n }\n }\n\nFormatting\n==========\n\nCurrently the format of sent messages is very simple: ``%(asctime)s %(levelname)s\\nFrom %(name)s:%(funcName)s\\n%(message)s``\nException traceback will be formatted as pre-formatted fixed-width code block. (https://core.telegram.org/bots/api#html-style)\n\nIf you want to tweak it, configure a ``telegram_handler.HtmlFormatter`` with your desired format string.\nUsing a dictConfig:\n\n.. code-block:: python\n \n ...\n {\n 'formatters': {\n 'telegram': {\n 'class': 'telegram_handler.HtmlFormatter',\n 'fmt': '%(levelname)s %(message)s'\n }\n }\n 'handlers': {\n 'telegram': {\n 'class': 'telegram_handler.TelegramHandler',\n 'formatter': 'telegram',\n 'token': 'your token',\n 'chat_id': 'chat id'\n }\n }\n }\n ...\n\nIf you wish, you can enable emoji symbols in HtmlFormatter. Just specify `use_emoji=True` in HtmlFormatter settings.\nThis will add to levelname a :white_circle: for DEBUG, :large_blue_circle: for INFO, and :red_circle: for WARNING and ERROR levels. \n\nProxy\n===========\n\nIn case if you have to use this package inside the country where Telegram servers are blocked by gowrnment you can specify proxy urls in config.\nUsing a dictConfig:\n\n.. code-block:: python\n \n ...\n {\n 'handlers': {\n 'telegram': {\n 'class': 'telegram_handler.TelegramHandler',\n 'formatter': 'telegram',\n 'token': 'your token',\n 'chat_id': 'chat id',\n 'proxies': {\n 'http': 'socks5://user:pass@host:port',\n 'https': 'socks5://user:pass@host:port'\n }\n }\n }\n }\n ...\n\n**Important!** If you plan to use *socks* proxy make sure you have ``requests`` package with ``socks`` support installed:\n\n.. code-block:: shell\n\n pip install requests[socks]\n\n\n.. :changelog:\n\nHistory\n-------\n\n2.1.0 (2019-04-25)\n++++++++++++++++++\n\n* Send message as file if it is too large\n* Fixes in MarkdownFormatter\n* Fixes in HTMLFormatter\n* Chat id retrieval fixes\n* Drop py33 support from tests\n* Update setup.py classifiers\n* Removed print()-calls in HtmlFormatter (#12) (by Lukas Garberg)\n\n\n2.0.2 (2017-11-20)\n++++++++++++++++++\n\n* fix TypeError in HtmlFormatter.format (by tompipen)\n\n\n2.0 (2017-03-01)\n++++++++++++++++\n\n* Refactored HtmlFormatter and MarkdownFormatter\n* Refactored TelegramHandler\n* No more need to call a command to obtain a chat_id - it will be obtained automatically on handler init\n* Rewritten tests\n* Escape LogRecord things in HtmlFormatter\n* Added optional emoji symbols in HtmlFormatter.\n\n1.1.3 (2016-09-22)\n++++++++++++++++++\n\n* Setting escape_message field of StyledFormatter missed (@ihoru)\n\n1.1.2 (2016-05-13)\n++++++++++++++++++\n\n* Fixed setup.py requires option (changed to install_requires)\n\n1.1.1 (2016-04-20)\n++++++++++++++++++\n\n* Use HTML Formatter as default formatter for telegram handler\n\n1.1.0 (2016-04-20)\n++++++++++++++++++\n\n* Introduced HTML Formatter\n* Added log text escaping (closed #3)\n* Added requests timeout setting (closed #1)\n* Catching and logging all requests and their exceptions (closed #2)\n\n1.0.0 (2016-04-19)\n++++++++++++++++++\n\n* First PyPi release\n\n0.1.0 (2016-04-19)\n++++++++++++++++++\n\n* Initial release", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/sashgorokhov/python-telegram-handler/archive/v2.2.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sashgorokhov/python-telegram-handler", "keywords": "telegram,logging,handler,bot", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "python-telegram-handler", "package_url": "https://pypi.org/project/python-telegram-handler/", "platform": "", "project_url": "https://pypi.org/project/python-telegram-handler/", "project_urls": { "Download": "https://github.com/sashgorokhov/python-telegram-handler/archive/v2.2.zip", "Homepage": "https://github.com/sashgorokhov/python-telegram-handler" }, "release_url": "https://pypi.org/project/python-telegram-handler/2.2/", "requires_dist": null, "requires_python": "", "summary": "A python logging handler that sends logs via Telegram Bot Api.", "version": "2.2" }, "last_serial": 5698904, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "cb674982c13fded3e643ba7f488a79cc", "sha256": "e32c4ec6949bc3707360736b73dce1474bde53ef15d7d7d2e153cc20363dc293" }, "downloads": -1, "filename": "python-telegram-handler-1.0.zip", "has_sig": false, "md5_digest": "cb674982c13fded3e643ba7f488a79cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7062, "upload_time": "2016-04-19T17:13:26", "url": "https://files.pythonhosted.org/packages/6e/0d/ac459ef0b86e627e379f3c219c5e6fd2e6145e855abd96d20213e7a41a77/python-telegram-handler-1.0.zip" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "ea8d8f4f1011bbaee2c88352020f1fe6", "sha256": "51fe37beb9accde0a715aa668fe98399e642058bd0085475ed7c74f1e71605ca" }, "downloads": -1, "filename": "python-telegram-handler-1.1.1.zip", "has_sig": false, "md5_digest": "ea8d8f4f1011bbaee2c88352020f1fe6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8721, "upload_time": "2016-04-20T20:22:44", "url": "https://files.pythonhosted.org/packages/41/d9/5c83ef2c71a9f711c2620a41330b523ab3dcf97ec9eab77bfd2b1b985db9/python-telegram-handler-1.1.1.zip" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "6729f6e7735d22c6f74e72d8447561ce", "sha256": "364b5eca86e8251ec44526a3098e83eeea37fae9d82c3f3026bbccf971936056" }, "downloads": -1, "filename": "python-telegram-handler-1.1.2.zip", "has_sig": false, "md5_digest": "6729f6e7735d22c6f74e72d8447561ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8810, "upload_time": "2016-05-13T08:40:31", "url": "https://files.pythonhosted.org/packages/99/ff/3a1ff567c4cb9c45ced836812a2d1006de926011a428d908480133d336ac/python-telegram-handler-1.1.2.zip" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "9a5e41fbce46651b9e9733faa6ee4d42", "sha256": "5f1ad74e6860fa0f23a81330904da9187562c2891dd4cfc8ab3deaffc6d1143f" }, "downloads": -1, "filename": "python-telegram-handler-1.1.3.zip", "has_sig": false, "md5_digest": "9a5e41fbce46651b9e9733faa6ee4d42", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8902, "upload_time": "2016-09-22T09:36:32", "url": "https://files.pythonhosted.org/packages/f9/a7/841f2cd90fc0907729ca85c1e79a7e80aee35334a6ca8312e11a4cc0c032/python-telegram-handler-1.1.3.zip" } ], "2.0": [ { "comment_text": "", "digests": { "md5": "dfb62d4a07cd10873a4fa98d0331576c", "sha256": "d327724f14c7cb72207cb467a6ca68deb4224b81de49704be6fdc29a4bcc04b1" }, "downloads": -1, "filename": "python-telegram-handler-2.0.tar.gz", "has_sig": false, "md5_digest": "dfb62d4a07cd10873a4fa98d0331576c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4648, "upload_time": "2017-03-01T10:06:40", "url": "https://files.pythonhosted.org/packages/a6/a2/0c1673e26395fa70878bc0fadf7fd2b96c5ed08e740948fabb9c5a90c7ac/python-telegram-handler-2.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "f4032105c4ff780c8c4cadd33322c477", "sha256": "30b2faf7d48a3270ebab1d0bcaff0448cfe1f47317fa90286960a242fa66adc6" }, "downloads": -1, "filename": "python-telegram-handler-2.0.1.tar.gz", "has_sig": false, "md5_digest": "f4032105c4ff780c8c4cadd33322c477", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4904, "upload_time": "2017-03-07T13:31:28", "url": "https://files.pythonhosted.org/packages/ca/d6/7c8a6190b4bd3632c3e619970d6732f3d6ff46ebbf75e2f7a7f68e6af298/python-telegram-handler-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "1ad56f4e8f679308082f9d9f45e7d64b", "sha256": "0ff904dff7d2b3b14a3d98880b818a7ddb2e21843898aad663b02d85d97f535f" }, "downloads": -1, "filename": "python-telegram-handler-2.0.2.tar.gz", "has_sig": false, "md5_digest": "1ad56f4e8f679308082f9d9f45e7d64b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5001, "upload_time": "2017-11-20T18:57:03", "url": "https://files.pythonhosted.org/packages/9f/38/4b839dd715172e4597a74b9a02d776b9a32293a07bde7e77f83a6ed9da84/python-telegram-handler-2.0.2.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "da7c96c17cc24a53786363bf1387970d", "sha256": "c3e8848fce6a838d3e29cbeb067543276f1abc1b6295bdc11468c303833fbd5d" }, "downloads": -1, "filename": "python-telegram-handler-2.1.0.tar.gz", "has_sig": false, "md5_digest": "da7c96c17cc24a53786363bf1387970d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5427, "upload_time": "2019-04-25T20:28:39", "url": "https://files.pythonhosted.org/packages/27/38/cacd69d4003bf63e7b9f2895eaf61584693e6c92d17b0e96e41a24fa30ab/python-telegram-handler-2.1.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "9c155bf5f7725354fef914b7e64c1088", "sha256": "bc9d5dd70fabc1234c357d497d340e902577c03ae53e68e619db6ce76cff5b87" }, "downloads": -1, "filename": "python-telegram-handler-2.1.1.tar.gz", "has_sig": false, "md5_digest": "9c155bf5f7725354fef914b7e64c1088", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5419, "upload_time": "2019-07-01T08:24:39", "url": "https://files.pythonhosted.org/packages/7e/8f/68210863443a1d252bb5b41041ccaf5796a9eb6df77429cb26c66b62021f/python-telegram-handler-2.1.1.tar.gz" } ], "2.2": [ { "comment_text": "", "digests": { "md5": "1a195b2e8c23a8ce6fe86fdfa41f77a8", "sha256": "0da65e9c9011b4269a339eb2cea778c82e4f3d5d92bda9a27f0fe3bb318e76f3" }, "downloads": -1, "filename": "python-telegram-handler-2.2.tar.gz", "has_sig": false, "md5_digest": "1a195b2e8c23a8ce6fe86fdfa41f77a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5680, "upload_time": "2019-08-19T14:59:43", "url": "https://files.pythonhosted.org/packages/99/18/0e0ffccb070320d9f76bcf3fe9604b96b576cc9ff0782712a14cd9bccaf6/python-telegram-handler-2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1a195b2e8c23a8ce6fe86fdfa41f77a8", "sha256": "0da65e9c9011b4269a339eb2cea778c82e4f3d5d92bda9a27f0fe3bb318e76f3" }, "downloads": -1, "filename": "python-telegram-handler-2.2.tar.gz", "has_sig": false, "md5_digest": "1a195b2e8c23a8ce6fe86fdfa41f77a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5680, "upload_time": "2019-08-19T14:59:43", "url": "https://files.pythonhosted.org/packages/99/18/0e0ffccb070320d9f76bcf3fe9604b96b576cc9ff0782712a14cd9bccaf6/python-telegram-handler-2.2.tar.gz" } ] }