Lightweight sink for Loguru that sends logs to Discord via webhook.
Project description
Loguru-Discord
Lightweight sink for Loguru that sends logs to Discord via webhook.
Usage
Construct a handler with your preferred options, then add a new sink to Loguru.
Installation
Support is guaranteed only for Python 3.12 or greater.
Once this requirement is met, simply install via your package manager of choice.
pip install loguru-discord
Example
The following code is a complete example which demonstrates:
- Constructing a handler
- Adding the handler as a Loguru sink
- Catching an exception and firing a log
from loguru import logger
from loguru_discord import DiscordSink
logger.add(DiscordSink("https://discord.com/api/webhooks/00000000/XXXXXXXX"))
try:
value: float = 1 / 0
except Exception as e:
logger.opt(exception=e).error("Lorem ipsum dolor sit amet")
Customization
Upon constructing your handler, the following optional customizations are available via keyword arguments.
- Username: Username to use for the Discord Webhook message.
- Avatar: Image URL to use for the Discord Webhook message.
- Embed: Toggle whether to use plain codeblock formatting or rich embeds.
- Truncate: Toggle whether to trim lengthy logs instead of uploading as a file.
- Suppress: Prevent specific Exception types from being sent to Discord.
Releases
Loguru-Discord follows Semantic Versioning for tagging releases of the project.
Contributing
Bug fixes and optimizations are always welcome. See CONTRIBUTING.md
for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file loguru_discord-1.4.0.tar.gz
.
File metadata
- Download URL: loguru_discord-1.4.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eab215b84f32c43406e601f9078803e810d3ee09d7e2717556708da8dbd381a2 |
|
MD5 | 4c6d6cb97b572ff6c070c1919bd4d58a |
|
BLAKE2b-256 | 67b11e263ae40b8506741e19c05139bb89c8f13f752721ca0c6c215d2dcf3c87 |
File details
Details for the file loguru_discord-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: loguru_discord-1.4.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ccc04a5c6de7996646734593d8ba430a0663f5cf844f79d31e6715fdf76163 |
|
MD5 | 992f71454b8b5fa3a46a4d0b16f09cac |
|
BLAKE2b-256 | b25c567c8300194ad0833d17e2c9b6187a58a8e500969cb6641fab6703e1e0f9 |