Telegram logging handler for python
Project description
Telegram logging handler for python
Provide your bot credentials to TelegramHandler:
from src.telegram_logging_handler import TelegramHandler
telegram_handler = TelegramHandler(
api_token="api_token",
chat_id="000000000"
)
For multiple chats you can provide a list of chat ids:
from src.telegram_logging_handler import TelegramHandler
telegram_handler = TelegramHandler(
api_token="api_token",
chat_id=["000000000", "11111111", "2222222"]
)
Use it with standard logging package:
import logging
from src.telegram_logging_handler import TelegramHandler
logger = logging.getLogger('my_logger')
telegram_handler = TelegramHandler(
api_token="api_token",
chat_id=["000000000", "11111111", "2222222"]
)
formatter = logging.Formatter('<b>%(asctime)s - %(levelname)s</b> - %(message)s')
telegram_handler.setFormatter(formatter)
logger.addHandler(telegram_handler)
logger.error('')
As you can see, handler also supports HTML tags inside formatter.
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
File details
Details for the file telegram_logging_handler-0.0.4.tar.gz
.
File metadata
- Download URL: telegram_logging_handler-0.0.4.tar.gz
- Upload date:
- Size: 13.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 633bc2df70f43576b82fa3217e90e3dfab92254753ddf9bb7523b042ec0305e5 |
|
MD5 | 06382d0c503aeef12bfab69395cd2a50 |
|
BLAKE2b-256 | 2369a3ac386a26adb7c3c32609ba03476d08e385c7732104d5bd53718660d582 |
File details
Details for the file telegram_logging_handler-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: telegram_logging_handler-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0857ea4ed898708197f5f7d43ec69f6680eb245457156b25137203aca8333861 |
|
MD5 | acc518d7c39b7901ded7bdfa7bd9a85d |
|
BLAKE2b-256 | 3930c6a7241faa18517af04b336d7854a02b0eee7897ce8277bac84c1864b131 |