Simple Telegram logging with zero dependencies.
Project description
telegram-logging
Simple Telegram logging with zero dependencies!
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-1.0.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for telegram_logging-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ccd6a94602e874d32ff7d395d0bed258a2bfa8f51d4d605ecc87b837acb764 |
|
MD5 | 80d62d4be31247776f8f48b511027361 |
|
BLAKE2b-256 | 160e2d18bf6b5bf5afd8a5ef1cd0d7eb7119a1f8cefd1dcedcf8055e464e73aa |