Custom handlers for standard logging module
Project description
Async handlers to throw logs to telegram and discord via Telegram Bot API and Discord Webhook
Note! These handlers are asynchronous, so the order of the logs is not guaranteed!
Usage:
Specify these environment variables:
TELEGRAM_CHANNEL_ID - telegram user of channel idTELEGRAM_TOKEN - token, that you can obtain from BotFatherSERVER_NAME - Machine name (useful, if you want to receive logs from different machines)DISCORD_WEBHOOK_URL - Webhook url for discord
You also can configure handlers directly
from custom_handlers.logging_handlers import DiscordHandler, TelegramHandler
import logging
from logging import Formatter
logger = logging.getLogger(__name__)
logger.setLevel("DEBUG")
handler = TelegramHandler(token="ABCD",
channel_id="1234567890",
formatter=Formatter("%(asctime)s - "))
handler.setLevel("DEBUG")
logger.addHandler(handler)
d_handler = DiscordHandler(sender_name="Again testing",
regular_message_text="regular message",
embeds_title="Embedded title",
)
d_handler.setLevel("DEBUG")
logger.addHandler(d_handler)
logger.error("Error log message")
logger.info("Info log message")
logger.debug("Debug log message")
logger.warning("Warning log message")
logger.critical("Critical log message")
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
Close
Hashes for external-logging-handlers-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61011529b4d216b716d1e9b81ff1c7d0dd4bc074ea10da663ab7b4df8bcb976b |
|
MD5 | c11c347e7eba4bda0360fb211c589845 |
|
BLAKE2b-256 | 0540926ea2d1dd4b4b6b029ae6470706ba1f9f8a9b27894ff5f9220e622eef2f |