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.3.tar.gz
.
File metadata
- Download URL: telegram_logging_handler-0.0.3.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 | d5e9ea34f820de38a77f1d8cb671ac7f4189d71cc80f66c0ac4b0a3a5c3a37aa |
|
MD5 | 289c54821ae1582444ec45794802c11f |
|
BLAKE2b-256 | 900f04b824a3334fb76077b793969d534160127829d825fb8280f9f968ce8286 |
File details
Details for the file telegram_logging_handler-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: telegram_logging_handler-0.0.3-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 | 5ceaeb31cb6efc6837ec2b71c364bb23f4125b92ecb0804153fbb9b37f740bc2 |
|
MD5 | 0e03a6b8c265fbb15a7446529df55cd9 |
|
BLAKE2b-256 | d84bbb664b7485c38c0c8a5653a2df544f7b14bd3ae1132d62829f9f50e79c43 |