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.2.tar.gz (13.7 MB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.2.tar.gz
Algorithm Hash digest
SHA256 68eb18d566066c5756a18f1f7822bebaf6a83cfc3a68e9705a90077e2c572230
MD5 30ac322d7e2e77b7e44dd968671a0183
BLAKE2b-256 ee1b8eb1a3e33cf03287bf9177bea7b9122d7ac86cf744a3d1d8d389dbbb8979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b39f723f4a0e68107ff2f9590e2356ba2b5a59ead5ee8744111ba72b09a99a
MD5 7453a4174f43d7dc32e0d5e75d0ec30f
BLAKE2b-256 738278d3d3adb827786aa0ef54511e2b94d15c850b5b5c76e8bd967ef3bf4e98

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