Skip to main content

Lightweight sink for Loguru that sends logs to Discord via webhook.

Project description

Loguru-Discord

PyPI - Python Version PyPI - Status PyPI - Downloads

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loguru_discord-1.3.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loguru_discord-1.3.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file loguru_discord-1.3.1.tar.gz.

File metadata

  • Download URL: loguru_discord-1.3.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for loguru_discord-1.3.1.tar.gz
Algorithm Hash digest
SHA256 a3c94e6286d1b161910a2e4d10f353039999349586f9c4caad727facd174b46a
MD5 58733befbf235f4c27905242bf39ff9d
BLAKE2b-256 546901d67866bf1a932566693a9748c6e8cf9732bd194513c2b6d6c1f02a879b

See more details on using hashes here.

File details

Details for the file loguru_discord-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: loguru_discord-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for loguru_discord-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0282affc34cb3c6844decc4e383b6bd3ef49d496114c11cb0ab6d59b867ab30
MD5 58b3e3cec2d4966079ff1f9fa8c836a1
BLAKE2b-256 a4efa4f3e4c060d6a0af74bf3a3771817333f48b9ff94cc8e260d9858434c4ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page