pip3 install git+https://github.com/Phinnik/telegram_logging_handler.git
import logging
from telegram_logging_handler import TelegramHandler
handler = TelegramHandler(bot_token, chat_id)
formatter = logging.Formatter(
fmt="<strong>%(levelname)s</strong>\n<i>%(name)s</i>\n\n%(message)s"
)
handler.setFormatter(formatter)
logger = logging.getLogger("LoggerName")
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
- Send some message to your bot
-
get_tg_chat_id <bot_token> <your_username>