A python package to stream your app logs to a telegram chat in realtime.
Project description
Telegram Logger
A simple python package to send your app logs to a telegram chat in realtime.
Installing
pip3 install git+https://github.com/eyMarv/tglogging.git
Example Usage
Add TelegramLogHandler
handler to your logging config.
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="OpDLBot",
ignore_match="error: floodwait",
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 send.
title
: a custom title you want to use in log message. Defaults to "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 send as a file. change according to your app.
LICENSE
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tglogging_black-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d79913648ffb99b029b044941f37623c8514c2d9be73649515df0e02e22d4d1c |
|
MD5 | df874c42150d25de0f901862e9cd66df |
|
BLAKE2b-256 | 7fb1c640cb0fa34f42e8d51e270f95f4f1fa1050aa580b2830bc90abf1d4ef12 |