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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.4.tar.gz
Algorithm Hash digest
SHA256 633bc2df70f43576b82fa3217e90e3dfab92254753ddf9bb7523b042ec0305e5
MD5 06382d0c503aeef12bfab69395cd2a50
BLAKE2b-256 2369a3ac386a26adb7c3c32609ba03476d08e385c7732104d5bd53718660d582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0857ea4ed898708197f5f7d43ec69f6680eb245457156b25137203aca8333861
MD5 acc518d7c39b7901ded7bdfa7bd9a85d
BLAKE2b-256 3930c6a7241faa18517af04b336d7854a02b0eee7897ce8277bac84c1864b131

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