tglogging-black


Nametglogging-black JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/eyMarv/tglogging
SummaryA python package to stream your app logs to a telegram chat in realtime.
upload_time2024-11-02 20:50:44
maintainerNone
docs_urlNone
authoreyMarv
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Telegram Logger 

> A simple yet powerful python package to send your app logs to a telegram chat in realtime.

<p align="center">
  <img src="images/tglogger.jpg" alt="Sample Image">
</p>

### Installing

``` bash
pip3 install -U tglogging-black
```

## Example Usage

Add ```TelegramLogHandler``` handler to your logging config.


```python
import logging
from tglogging import TelegramLogHandler

# TelegramLogHandler is a custom handler which is inherited from an existing handler. ie, StreamHandler.

logging.basicConfig(
    level=logging.INFO,
    format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
    datefmt='%d-%b-%y %H:%M:%S',
    handlers=[
        TelegramLogHandler(
            token="12345678:AbCDEFGhiJklmNoPQRTSUVWxyZ", 
            log_chat_id=-10225533666,
            forum_msg_id=24,
            title="@AltCakeBot",
            ignore_match=["error: floodwait", "scheduler execution delayed"],
            update_interval=2, 
            minimum_lines=1, 
            pending_logs=200000),
        logging.StreamHandler()
    ]
)

logger = logging.getLogger(__name__)

logger.info("live log streaming to telegram.")

```
## Parameters

```token``` : A telegram bot token to interact with telegram API.

```log_chat_id``` : Chat id of chat to which logs are to be sent.

```forum_msg_id``` : [Optional] Forum Topic ID where to send the logs to.

```title``` : a custom title you want to use in log message. Defaults to "TGLogger"

```ignore_match``` : Specify what lines need to contain, in order to be ignored by TGLogger.

```update_interval```: Interval between two posting in seconds. Lower intervals will lead to floodwaits. Default to 5 seconds.

```minimum_lines```: Minimum number of new lines required to post / edit a message.

```pending_logs```: Maximum number of characters for pending logs to send as file.
default to 200000. this means if the app is producing a lot of logs within short span of time, if the pending logs exceeds 200000 characters it will be sent as a file. change according to your app.


## LICENSE

- [MIT License](./LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eyMarv/tglogging",
    "name": "tglogging-black",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "eyMarv",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/23/52/3094234cacb9bb41391cddf32995afb1e0cef8360ae035978510613e6096/tglogging_black-0.1.8.tar.gz",
    "platform": null,
    "description": "# Telegram Logger \r\n\r\n> A simple yet powerful python package to send your app logs to a telegram chat in realtime.\r\n\r\n<p align=\"center\">\r\n  <img src=\"images/tglogger.jpg\" alt=\"Sample Image\">\r\n</p>\r\n\r\n### Installing\r\n\r\n``` bash\r\npip3 install -U tglogging-black\r\n```\r\n\r\n## Example Usage\r\n\r\nAdd ```TelegramLogHandler``` handler to your logging config.\r\n\r\n\r\n```python\r\nimport logging\r\nfrom tglogging import TelegramLogHandler\r\n\r\n# TelegramLogHandler is a custom handler which is inherited from an existing handler. ie, StreamHandler.\r\n\r\nlogging.basicConfig(\r\n    level=logging.INFO,\r\n    format=\"[%(asctime)s - %(levelname)s] - %(name)s - %(message)s\",\r\n    datefmt='%d-%b-%y %H:%M:%S',\r\n    handlers=[\r\n        TelegramLogHandler(\r\n            token=\"12345678:AbCDEFGhiJklmNoPQRTSUVWxyZ\", \r\n            log_chat_id=-10225533666,\r\n            forum_msg_id=24,\r\n            title=\"@AltCakeBot\",\r\n            ignore_match=[\"error: floodwait\", \"scheduler execution delayed\"],\r\n            update_interval=2, \r\n            minimum_lines=1, \r\n            pending_logs=200000),\r\n        logging.StreamHandler()\r\n    ]\r\n)\r\n\r\nlogger = logging.getLogger(__name__)\r\n\r\nlogger.info(\"live log streaming to telegram.\")\r\n\r\n```\r\n## Parameters\r\n\r\n```token``` : A telegram bot token to interact with telegram API.\r\n\r\n```log_chat_id``` : Chat id of chat to which logs are to be sent.\r\n\r\n```forum_msg_id``` : [Optional] Forum Topic ID where to send the logs to.\r\n\r\n```title``` : a custom title you want to use in log message. Defaults to \"TGLogger\"\r\n\r\n```ignore_match``` : Specify what lines need to contain, in order to be ignored by TGLogger.\r\n\r\n```update_interval```: Interval between two posting in seconds. Lower intervals will lead to floodwaits. Default to 5 seconds.\r\n\r\n```minimum_lines```: Minimum number of new lines required to post / edit a message.\r\n\r\n```pending_logs```: Maximum number of characters for pending logs to send as file.\r\ndefault to 200000. this means if the app is producing a lot of logs within short span of time, if the pending logs exceeds 200000 characters it will be sent as a file. change according to your app.\r\n\r\n\r\n## LICENSE\r\n\r\n- [MIT License](./LICENSE)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python package to stream your app logs to a telegram chat in realtime.",
    "version": "0.1.8",
    "project_urls": {
        "Homepage": "https://github.com/eyMarv/tglogging",
        "Source": "https://github.com/eyMarv/tglogging",
        "Tracker": "https://github.com/eyMarv/tglogging/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "87582a868066d049d8845d1a8a4eb33a5a17e4768a93a11979f4f4a37c45d9bf",
                "md5": "cbbeb97e44a1484613578a8876023300",
                "sha256": "e0316be7aa75cb7d1d0e15cb7761fda6fdfd5dfb2c5dabab7e0334bfb18c464e"
            },
            "downloads": -1,
            "filename": "tglogging_black-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cbbeb97e44a1484613578a8876023300",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5841,
            "upload_time": "2024-11-02T20:50:43",
            "upload_time_iso_8601": "2024-11-02T20:50:43.679948Z",
            "url": "https://files.pythonhosted.org/packages/87/58/2a868066d049d8845d1a8a4eb33a5a17e4768a93a11979f4f4a37c45d9bf/tglogging_black-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "23523094234cacb9bb41391cddf32995afb1e0cef8360ae035978510613e6096",
                "md5": "6e2e0e306836a441dfd55bc0bfccf132",
                "sha256": "6b91236b7c06ec54b16dcc4befca23afb5829c3eb28abc2200622f45619093db"
            },
            "downloads": -1,
            "filename": "tglogging_black-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "6e2e0e306836a441dfd55bc0bfccf132",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5296,
            "upload_time": "2024-11-02T20:50:44",
            "upload_time_iso_8601": "2024-11-02T20:50:44.981335Z",
            "url": "https://files.pythonhosted.org/packages/23/52/3094234cacb9bb41391cddf32995afb1e0cef8360ae035978510613e6096/tglogging_black-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-02 20:50:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eyMarv",
    "github_project": "tglogging",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tglogging-black"
}
        
Elapsed time: 0.34495s