Forward Loguru logs to Discord webhooks.
Loguru-Discord is a lightweight sink for Loguru that forwards logs to Discord via the Webhook API.
- Plug-and-play adoption with your existing logging structure
- Configurable usernames, avatars, rich formatting, and attachments for oversized messages
- Fully type-hinted for an excellent developer experience
- Native and performant Webhook API interaction powered by Clyde
- Opt-in interception of standard library logging events, unified under Loguru
Important
Loguru-Discord requires Python 3.11 or later.
Install with uv (recommended):
uv add loguru-discordAlternatively, install with pip:
pip install loguru-discordReplace the placeholder with your Discord webhook URL:
from loguru import logger
from loguru_discord import DiscordSink
# Construct the Discord handler
sink: DiscordSink = DiscordSink(
"https://discord.com/api/webhooks/00000000/XXXXXXXX", rich=True
)
# Add the sink to Loguru
logger.add(sink)
# Log an exception
try:
value: float = 1 / 0
except Exception as e:
logger.opt(exception=e).error("Calculation failed")See the documentation for more examples and configuration options.
Loguru-Discord loosely follows Semantic Versioning for consistent, predictable releases.
See the contributor guide to report bugs, propose features, or work on documentation.
- See
CONTRIBUTING.mdfor guidelines. - See Issues for known bugs and feature requests.
This project is not affiliated with or endorsed by Loguru or Discord in any way.
