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.

Source Distribution

discordlogger-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

discordlogger-0.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: discordlogger-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 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.2.tar.gz
Algorithm Hash digest
SHA256 93ebcd2fe18e2eabe0e4d2fc2e761c96670f62b054c526d9ea1b1f6f8fbc4e4f
MD5 c09db62249ba9beae14b3549616bc36a
BLAKE2b-256 62f7bf5a34b12b7a67632a53984e9e1586faad2b404e59ca5c764cbf330ee216

See more details on using hashes here.

File details

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

File metadata

  • Download URL: discordlogger-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2812ba0dfef20c02314a6c738eba86a1cf2b1a98f8493e9a005ce89f2c9077df
MD5 5b8a09f24e7f8cfa9e9d90e63cb71a89
BLAKE2b-256 38247732ec184aab95603dc8d39152d80b7ba162c926da65fe13e138bc089a91

See more details on using hashes here.

Supported by

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