Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

EthanC/Loguru-Discord

Repository files navigation

PythonGitHub Workflow StatusPyPI DownloadsCoverage Report

Loguru-Discord is a lightweight sink forLoguru that forwards logs toDiscord 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 byClyde

Preview

Getting Started

Installation

Important

Loguru-Discord requires Python 3.11 or later.

Install withuv (recommended):

uv add loguru-discord

Alternatively, install with pip:

pip install loguru-discord

Handler

You can integrate Loguru-Discord in just two lines:

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

All configuration is handled onDiscordSink via optional keyword arguments.

ArgumentDescriptionDefault
webhook_urlDiscord Webhook URL to forward log events to.N/A (Required)
usernameString to use for the Webhook username.None (Determined by Discord)
avatar_urlImage URL to use for the Webhook avatar.None (Determined by Discord)
richToggle whether to use Discord Components.False
suppressList of Exception types to not forward to Discord.None

Example

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

fromloguruimportloggerfromloguru_discordimportDiscordSink# Construct the Discord handlersink:DiscordSink=DiscordSink("https://discord.com/api/webhooks/00000000/XXXXXXXX")# Add the sink to Logurulogger.add(sink)# Log an exceptiontry:value:float=1/0exceptExceptionase:logger.opt(exception=e).error("Lorem ipsum dolor sit amet")

Releases

Loguru-Discord loosely followsSemantic 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.

Sponsor this project

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp