Lightweight, easy-to-use Discord sink for Loguru.
Project description
Loguru-Discord
Lightweight, easy-to-use Discord sink for Loguru.
Usage
Construct a handler with your preferred options, then add a new sink to Loguru.
Installation
Support is guaranteed only for Python 3.11 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.
- 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
Hashes for loguru_discord-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65d663c1e48c75c350219653192fdf186594cb7114746a329103cb4a8967982 |
|
MD5 | 0730475a42526137de3037ce11f379b7 |
|
BLAKE2b-256 | 285613c3cb55780370651bd1dcd811dcf31ea16d616da62c71617d6b9a72f64d |