tglogger is a logger handler and formatter for Telegram bots.
Project description
tglogger
tglogger
contains utilities to build and redirect logs to Telegram chat via a bot.
- It has a formatter for beautiful log messages in Telegram.
- It tends to tag common logs so that you can easily filter out related log messages.
- You can send logs to individuals, channels or groups.
- It works with Django (See badges for supported versions).
Build | Coverage | |
---|---|---|
master | ||
development |
Installing
Install via pip
:
pip install tglogger
Example
tglogger
contains a formatter which formats log records for Telegram chats and a handler which sends log records to a Telegram chat.
Assuming you have a logger instance:
logger = logging.getLogger(__name__)
You need to have an instance of TelegramHandler
and TelegramFormatter
.
from tglogger import TelegramHandler, TelegramFormatter
handler = TelegramHandler(bot_token="foo", receiver="bar")
# you can also set TELEGRAM_BOT_TOKEN and TELEGRAM_RECEIVER
# environment variables so as not to pass these on initialization
formatter = TelegramFormatter() # initialize formatter
handler.setFormatter(formatter) # inject formatter into handler
logger.addHandler(handler) # inject handler into logger
And now your log records that has level above ERROR
will be sent to the chat you have defined with receiver
by the bot that you have defined by bot_token
.
logger.error("foo") # you will receive a message by your bot
Documentation
Documentation has more information about how to use tglogger
. Refer to the documentation.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file tglogger-0.1.1a3.tar.gz
.
File metadata
- Download URL: tglogger-0.1.1a3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81f9ffa4eb5fbd5b8bc2fb94a82853f0424b754f0eb86a30781eb31bffbba8e5 |
|
MD5 | 6002fb6c3de71e2eaa970caace57b0db |
|
BLAKE2b-256 | 8d9e3f83846ee6c251ac76f939b4ba3d62723de1780460f43a61723d1c430c2b |
File details
Details for the file tglogger-0.1.1a3-py3-none-any.whl
.
File metadata
- Download URL: tglogger-0.1.1a3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31d79a0e2fd78b65024a8edf1b1ace713defcc6b4502642fb8048f58c3ccf6a8 |
|
MD5 | d1c8210446985ad0165edbbfd00fb388 |
|
BLAKE2b-256 | 081b38923f3e6d75cb009502680dcadd9701835002ef9e0a0ac00b1825d5479c |