Skip to main content

A lightweight sink for Loguru that forward logs to Discord via the Webhook API.

Project description

Loguru-Discord

Python GitHub Workflow Status PyPI Downloads Coverage Report

Loguru-Discord is a lightweight sink for Loguru that forwards logs to Discord via the Webhook API.

Features

  • Plug-and-play adoption with your existing logging structure
  • Highly configurable presentation, from usernames and avatars to rich formatting and truncation
  • Fully type-hinted for an excellent developer experience
  • Native and performant Webhook API interaction powered by Clyde

Preview

Getting Started

Installation

[!IMPORTANT] Loguru-Discord requires Python 3.11 or later.

Install with uv (recommended):

uv add loguru-discord

Alternatively, install with pip:

pip install loguru-discord

Handler

You can integrate Loguru-Discord in just two lines:

from loguru_discord import DiscordSink

logger.add(DiscordSink("https://discord.com/api/webhooks/00000000/XXXXXXXX"))

All configuration is handled on DiscordSink via optional keyword arguments.

Argument Description Default
webhook_url Discord Webhook URL to forward log events to. N/A (Required)
username String to use for the Webhook username. None (Determined by Discord)
avatar_url Image URL to use for the Webhook avatar. None (Determined by Discord)
rich Toggle whether to use Discord Components. False
suppress List of Exception types to not forward to Discord. None

Example

Here’s a complete, end-to-end example using Loguru-Discord:

from loguru import logger
from loguru_discord import DiscordSink

# Construct the Discord handler
sink: DiscordSink = DiscordSink("https://discord.com/api/webhooks/00000000/XXXXXXXX")

# 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("Lorem ipsum dolor sit amet")

Releases

Loguru-Discord loosely follows Semantic Versioning for consistent, predictable releases.

Contributing

Contributions are welcome—whether it’s fixing bugs or adding new features.

Acknowledgments

This project is not affiliated with or endorsed by Loguru or Discord in any way.

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-2.0.0.tar.gz (113.4 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-2.0.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loguru_discord-2.0.0.tar.gz
  • Upload date:
  • Size: 113.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for loguru_discord-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1320096fe2e1adf0efcdb1412607ba0f03a0b5835d21743b0951ca68a9b00684
MD5 b515291ff951d16b150c1b134857c176
BLAKE2b-256 1662eb34c068a35e8d1e2ad654097be4b9e158d6d56749d97fa40175cc3f8588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loguru_discord-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for loguru_discord-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90917fc28587429f415170b261039e6abfabc5f0ccca0338eacff600efa4fe43
MD5 9e0d4c77e3ecb003acb265e3fc0998fd
BLAKE2b-256 30a78d9259e1659c479c0d0641e4386401fd9ce66c9b26d73b886bcf482b0df3

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