external-logging-handlers-0.1.4
توضیحات
Custom handlers for standard logging module
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | external-logging-handlers-0.1.4 |
| نام | external-logging-handlers |
| نسخه کتابخانه | 0.1.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Alexander |
| ایمیل نویسنده | bf-109g@yandex.ru |
| آدرس صفحه اصلی | https://github.com/alexvoksa/logging-handlers |
| آدرس اینترنتی | https://pypi.org/project/external-logging-handlers/ |
| مجوز | MIT License |
Custom handlers
===============
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 id
| ``TELEGRAM_TOKEN`` - token, that you can obtain from BotFather
| ``SERVER_NAME`` - Machine name (useful, if you want to receive logs
from different machines)
| ``DISCORD_WEBHOOK_URL`` - Webhook url for discord
| Special discord parameters `Open Discord
docs <https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html>`__
| SENDER_NAME
| REGULAR_MESSAGE_TEXT
| EMBEDS_TITLE
You also can configure handlers directly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
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")
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9.1 | Python |
نحوه نصب
نصب پکیج whl external-logging-handlers-0.1.4:
pip install external-logging-handlers-0.1.4.whl
نصب پکیج tar.gz external-logging-handlers-0.1.4:
pip install external-logging-handlers-0.1.4.tar.gz