Skip to main content

tglogger is a logger handler and formatter for Telegram bots.

Project description

tglogger

PyPI - Version PyPI - Status PyPI - License PyPI - Python PyPI - Django Downloads - Month

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

  • It has a formatter for beautiful log messages in Telegram.
  • It tends to tag common logs so that you can easily filter out related log messages.
  • You can send logs to individuals, channels or groups.
  • It works with Django (See badges for supported versions).
Build Coverage
master Linux - Master Coverage - Master
development Linux - Development Coverage - Development

Installing

Install via pip:

pip install tglogger

Example

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 and TelegramFormatter.

from tglogger import TelegramHandler, TelegramFormatter

handler = TelegramHandler(bot_token="foo", receiver="bar")
# you can also set TELEGRAM_BOT_TOKEN and TELEGRAM_RECEIVER
# 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 receive a message by your bot

Documentation

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.1a3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

tglogger-0.1.1a3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file tglogger-0.1.1a3.tar.gz.

File metadata

  • Download URL: tglogger-0.1.1a3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10

File hashes

Hashes for tglogger-0.1.1a3.tar.gz
Algorithm Hash digest
SHA256 81f9ffa4eb5fbd5b8bc2fb94a82853f0424b754f0eb86a30781eb31bffbba8e5
MD5 6002fb6c3de71e2eaa970caace57b0db
BLAKE2b-256 8d9e3f83846ee6c251ac76f939b4ba3d62723de1780460f43a61723d1c430c2b

See more details on using hashes here.

File details

Details for the file tglogger-0.1.1a3-py3-none-any.whl.

File metadata

  • Download URL: tglogger-0.1.1a3-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10

File hashes

Hashes for tglogger-0.1.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 31d79a0e2fd78b65024a8edf1b1ace713defcc6b4502642fb8048f58c3ccf6a8
MD5 d1c8210446985ad0165edbbfd00fb388
BLAKE2b-256 081b38923f3e6d75cb009502680dcadd9701835002ef9e0a0ac00b1825d5479c

See more details on using hashes here.

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