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.1.tar.gz (113.1 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.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loguru_discord-2.0.1.tar.gz
  • Upload date:
  • Size: 113.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.tar.gz
Algorithm Hash digest
SHA256 f4ed421a848648566c05575b2515ec898e1abe447e7aa427e3538fc0f6cc2ff9
MD5 3fe7fdee397eeaa02c5ee7660b2580cb
BLAKE2b-256 ae49cac5b336b3ba64305b58290f432de3c5c6f3d8ebabdf86cde999bbca5a4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loguru_discord-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5821ac94b674589ed3de9cfe5e0751111d122335c1182a1c4ec071aeef8e389c
MD5 d3703dcc77f895a98bc9064bab95dfa0
BLAKE2b-256 94fb3793be9d1c901392cff2c0959cbe9f0cd62ca4b4c94581319c4cd2e71168

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