Skip to main content

A Python logger to send information to Discord Webhooks.

Project description

discord-logger

A Python logger to send information to Discord Webhooks.

Installation

Install this package via pip by executing pip install discordlogger

Usage

Basic Usage

import logging

from discordlogger import DiscordFormatter

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
h = DiscordHandler(webhook_url=URL)
h.setLevel(logging.INFO)
logger.addHandler(h)

logger.info('Hello World')

Advanced Formating

import logging

from discordlogger import DiscordFormatter, DiscordHandler

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
h = DiscordHandler(webhook_url=URL)
h.addFormatter(DiscordFormatter())
logger.addHandler(h)

logger.info('Hello World')
logger.warning('Warning!')
try:
    print(data['hello'])
except Exception:
    logger.exception('Exception!')
logger.critical('Emergency here!')

Filtering

import logging

from discordlogger import DiscordFormatter, DiscordLogFilter

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
h = DiscordHandler(webhook_url=URL)
h.addFilter(DiscordLogFilter())
logger.addHandler(h)

# Now this doesn't activate the discord webhook
logger.info("Hello World")

# Whereas this does
logger.info("Hello World", extra={'notify_discord': True})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for discordlogger, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size discordlogger-0.0.2-py3-none-any.whl (3.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size discordlogger-0.0.2.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page