Skip to main content

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",
        embed=True
    ),
    level="WARNING",
)

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.

Releases

Loguru-Discord follows Semantic Versioning for tagging releases of the project.

Changelogs can be found on the Releases page in the Keep a Changelog format.

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.0.1.tar.gz (3.8 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.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loguru_discord-1.0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for loguru_discord-1.0.1.tar.gz
Algorithm Hash digest
SHA256 70abd8d486b9c9b8f60dc4fe29231142c0d56547facaec4f58e15710ba6f7ea1
MD5 5953600c4cc5db7db477ff099ccc6aa8
BLAKE2b-256 e2d31281886c302d6fabe26bda50e9eae3661f5bb22e2ec21df536adedba359d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loguru_discord-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for loguru_discord-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1248cb57bb2eba40fca4fcf519f489c4409ccbe189482e1a16c924169dba79ec
MD5 0b84735bd66906ef251ce5494ea77519
BLAKE2b-256 1f51686a9dd881b73e84b18a2c3222c7e182453337f28b5f6b434a23b6166f5e

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