Skip to main content

A logging handler that sends log messages to Discord via webhooks.

Project description

Discord Logger

A simple, flexible Discord logging package that sends logs to Discord channels via webhooks.

Installation

pip install discord-logger-handler

Quick Start

from discord_logger import DiscordLogger

# Initialize the logger
logger = DiscordLogger(
    webhook_url="your_discord_webhook_url",
    app_name="MyApp",
    min_level="DEBUG"  # Optional, defaults to "DEBUG"
)

# Send logs at different levels
logger.debug("Debug message", extra_field="debug value")
logger.info("Info message", user="john_doe")
logger.warning("Warning message", system_resources="running low")
logger.error("Error message", error_code=500)
logger.critical("Critical message", affected_users=1000)

Features

  • Multiple log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Custom fields support via kwargs
  • Color-coded embeds in Discord
  • Fallback to standard Python logging
  • Timezone-aware timestamps
  • Simple and intuitive API

Configuration

The logger can be configured with the following parameters:

  • webhook_url: Your Discord webhook URL
  • app_name: Name of your application (appears in log titles)
  • min_level: Minimum logging level to process

Examples

Basic Usage

logger = DiscordLogger("webhook_url", "MyApp")
logger.info("User logged in", user_id="123", ip="192.168.1.1")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file 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

discord_logger_handler-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

discord_logger_handler-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file discord_logger_handler-0.1.1.tar.gz.

File metadata

  • Download URL: discord_logger_handler-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for discord_logger_handler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b199fa03ea0e5686798395a08ffdc6a66c0f45bc7bda6c12cf59ea85224fa47c
MD5 a48001db062b2f582831373ba54ba52d
BLAKE2b-256 eb110fad782975e155f6574a3dae7aa06b6a28ac44f5fe85782beec27a671d9e

See more details on using hashes here.

File details

Details for the file discord_logger_handler-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for discord_logger_handler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 20d3470f913f532a3af52b058c4aaaaa696b04d857c563ced1d210ed25350e0e
MD5 37a59b6a34e45634a61370f1a8469714
BLAKE2b-256 e5fb868dc6254a6afec7a283512098771817e4c0670f2737d6d8d48bc977b61f

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