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.formatter = 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.

Source Distribution

discordlogger-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

discordlogger-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file discordlogger-0.0.1.tar.gz.

File metadata

  • Download URL: discordlogger-0.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for discordlogger-0.0.1.tar.gz
Algorithm Hash digest
SHA256 71d183a0eeb53042123f8758f0dd80b04372160a7356085804210db7121a08ca
MD5 894fde9a4f882446ebcbeb2bdf3b541d
BLAKE2b-256 99da0610ed3c582c293f9c0e2e858624954c597632866425de28c78e3f980750

See more details on using hashes here.

File details

Details for the file discordlogger-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: discordlogger-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for discordlogger-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 528314a27fe9fdd45e87ac12a516ce49f043a2184e93837d453a199f0d405806
MD5 e85bf7213838ee32ee223a5fdd214fcd
BLAKE2b-256 b78fba1b230069d0cf5cd898b26710367f6f0fad9600336eccc3b9e80ef1e147

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page