A python log handler that sends log messages via a Telegram bot.
- create a bot via the BotFather
- take note of the bot's
token
provided by the botfather - add the bot to your contacts and sent it a message
- Use the
getUpdates
API method to retrive yourchat_id
- YOu can do that by point your browser at
https://api.telegram.org/bot{token}/getUpdates
and look for anid
element inside achat
element
- YOu can do that by point your browser at
Run the following command: pip install git+https://github.com/simonacca/TelegramLogHandler/
import logging
from TelegramHandler import TelegramHandler
logger = logging.getLogger()
streamHandler = logging.StreamHandler()
tgHandler = TelegramHandler('myToken', ['myId'])
logger.addHandler(streamHandler)
logger.addHandler(tgHandler)
logging.error('TestMessage')