A simple Telegram logging module with Handler and Formatter.
Project description
telegram-logging
A simple Telegram logging module with Handler and Formatter.
https://pypi.org/project/telegram-logging/
Usage:
➡️ See a full example in examples/usage.py
🤖 How to create a Telegram bot
Install:
pip install telegram-logging
Import:
from telegram_logging import TelegramHandler, TelegramFormatter
Create a Formatter and a Handler:
formatter = TelegramFormatter(
fmt="[%(asctime)s %(name)s] %(levelname)8s\n\n%(message)s",
datefmt="%d/%m/%Y %H:%M:%S",
use_emoji=True)
handler = TelegramHandler(
token="<Your bot token>",
chat_id="<Your chat id>")
handler.setFormatter(formatter)
*You can get a list of all available handler params here
Use it:
import logging
logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.info("Hi, here is some information")
Default Emojis:
Emoji | Level |
---|---|
⚪️ | DEBUG |
🔵 | INFO |
🟠 | WARNING |
🔴 | ERROR |
🔥 | CRITICAL |
You can use your own set of emojis:
formatter = TelegramFormatter(
format="[%(asctime)s %(name)s] %(levelname)8s\n\n%(message)s",
datefmt="%d/%m/%Y %H:%M:%S",
use_emoji=True,
emoji_map={
logging.DEBUG: "🐛",
logging.INFO: "💡",
logging.ERROR: "🚨",
})
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
telegram_logging-0.16.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for telegram_logging-0.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8c950bd8ddc840be97d234d761a003201a67c86565452b44b8171749e6fc5b |
|
MD5 | 68bc6ed71497fc6cffa0dd3624cbef10 |
|
BLAKE2b-256 | 4a4edd499031f653b0799cb2d0d935de7976ed8de799e10e2fd17f6fbee65ff1 |