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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d5e9ea34f820de38a77f1d8cb671ac7f4189d71cc80f66c0ac4b0a3a5c3a37aa
MD5 289c54821ae1582444ec45794802c11f
BLAKE2b-256 900f04b824a3334fb76077b793969d534160127829d825fb8280f9f968ce8286

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for telegram_logging_handler-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5ceaeb31cb6efc6837ec2b71c364bb23f4125b92ecb0804153fbb9b37f740bc2
MD5 0e03a6b8c265fbb15a7446529df55cd9
BLAKE2b-256 d84bbb664b7485c38c0c8a5653a2df544f7b14bd3ae1132d62829f9f50e79c43

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