simonacca / TelegramLogHandler

Python log handler that sends logs via Telegram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telegram Log Handler

A python log handler that sends log messages via a Telegram bot.

Deployment Instructions

Bot setup

  • 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 your chat_id
    • YOu can do that by point your browser at https://api.telegram.org/bot{token}/getUpdates and look for an id element inside a chat element

Handler setup

Run the following command: pip install git+https://github.com/simonacca/TelegramLogHandler/

Handler usage

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')

About

Python log handler that sends logs via Telegram

License:MIT License


Languages

Language:Python 100.0%