Skip to main content

Telegram logging handler for python

Project description

Telegram logging handler for python

Provide your bot credentials to TelegramHandler:

from src.telegram_logging_handler import TelegramHandler

telegram_handler = TelegramHandler(
    api_token="api_token",
    chat_id="000000000"
)

For multiple chats you can provide a list of chat ids:

from src.telegram_logging_handler import TelegramHandler

telegram_handler = TelegramHandler(
    api_token="api_token",
    chat_id=["000000000", "11111111", "2222222"]
)

Use it with standard logging package:

import logging

from src.telegram_logging_handler import TelegramHandler

logger = logging.getLogger('my_logger')
telegram_handler = TelegramHandler(
    api_token="api_token",
    chat_id=["000000000", "11111111", "2222222"]
)
formatter = logging.Formatter('<b>%(asctime)s - %(levelname)s</b> - %(message)s')
telegram_handler.setFormatter(formatter)
logger.addHandler(telegram_handler)
logger.error('')

As you can see, handler also supports HTML tags inside formatter.

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

telegram_logging_handler-0.0.5.tar.gz (13.7 MB view details)

Uploaded Source

Built Distribution

telegram_logging_handler-0.0.5-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file telegram_logging_handler-0.0.5.tar.gz.

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.5.tar.gz
Algorithm Hash digest
SHA256 ccb081c9d67993503a41bf167a4f027b671e19ebe747d308ce702ef4a2582173
MD5 f0e7a166fd86defaf692bda9ac8e427f
BLAKE2b-256 a1374addcae30d1f63dd238a257cb97218f4dcd77f9313d9a1ceb7d38fbbe642

See more details on using hashes here.

File details

Details for the file telegram_logging_handler-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b8a8ba7bdfadc623851303d51fec1ce975dccd0e7748a8e07ca42103d369ee26
MD5 cb9faf93bedf6c87a51e85bb2b772432
BLAKE2b-256 77a26b862e654a4c49d5eef6797af2b095eca251e6e0eb1c7e3adf9ab6f3de84

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