Skip to main content

tglogger is a logger handler and formatter for Telegram bots.

Project description


PyPI PyPI PyPI PyPI PyPI - Django Version PyPI Telegram Code Style

tglogger contains utilities to build and redirect logs to Telegram chat via a bot.

Build Coverage
Master Travis (.com) master Codecov (master)
Development Travis (.com) development Codecov (development)


Install via pip:

pip install tglogger


tglogger contains a formatter which formats log records for Telegram chats and a handler which sends log records to a Telegram chat.

Assuming you have a logger instance:

logger = logging.getLogger(__name__)

You need to have an instance of TelegramHandler handler TelegramFormatter.

from tglogger import TelegramHandler, TelegramFormatter

handler = TelegramHandler(bot_token="foo", receiver="bar")
# environment variables so as not to pass these on initialization

formatter = TelegramFormatter() # initialize formatter
handler.setFormatter(formatter)  # inject formatter into handler

logger.addHandler(handler)  # inject handler into logger

And now your log records that has level above ERROR will be sent to the chat you have defined with receiver by the bot that you have defined by bot_token.

logger.error("foo")  # you will receiver message by your bot


Documentation has more information about how to use tglogger. Refer to the documentation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tglogger-0.1.0b1.tar.gz (4.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page