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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.1.tar.gz
Algorithm Hash digest
SHA256 52ee82e124d1d6ae6bdffdba370528f29ef4527083d5772b1b2e5ac4907fd434
MD5 3424a00fa981e5dc536480fed5f25853
BLAKE2b-256 b73bf524198c631338c85a8e156325e8dae1c8c037a365f7fff9edf0d51df67a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2e720bd4b8cda5a02baeea81cf8d29de7f186c70eba1c8b7101cc2234d30087
MD5 1e646ec1455f9089f6573c2dfd55b9d5
BLAKE2b-256 f1506e1c3b50bf873b6fdc415753fea07d688e95bce0fc8ddb59c37f5ac97a4c

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