Skip to main content

Logging handler to send messages to a Slack channel.

Project description

PyPi Code style License Versions CodeFactor

Simple logging with Slack

It helps you to receive all logs from your Python code in Slack channels using webhooks.

Install from PyPi:
pip install simple-slack-logger

or from repository:
pip install git+https://github.com/gixproject/simple-slack-logger

Usage

Explicit usage

import logging
from slack_logger import SlackHandler

logger = logging.getLogger(__name__)
handler = SlackHandler(webhook="<YOUR_WEBHOOK>")
logger.addHandler(handler)
logger.error("Something bad happened")

Logging config

"handlers": {
    "slack": {
        "class": "slack_logger.SlackHandler",
        "formatter": "default",
        "level": "WARNING",
        "webhook": "<YOUR_WEBHOOK>",
    },
}

Hint

To catch all exceptions from your Python code you can use this in the main module:

def logging_except_hook(exc_type, exc_value, exc_traceback):
    logging.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))


sys.excepthook = logging_except_hook

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

simple-slack-logger-0.6.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

simple_slack_logger-0.6.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file simple-slack-logger-0.6.0.tar.gz.

File metadata

  • Download URL: simple-slack-logger-0.6.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.14.18-1-MANJARO

File hashes

Hashes for simple-slack-logger-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e3e1fb579174085fa48d23280e89ef6c63e1b357220a814ccc24f2c02bd995d3
MD5 85b27a5d9b3b60ef86289f97e29cee2c
BLAKE2b-256 af365e197d109dc29da9cb0225462a5cf953d8b0560b42a9bb9e4eeaa2b376fa

See more details on using hashes here.

File details

Details for the file simple_slack_logger-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: simple_slack_logger-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.14.18-1-MANJARO

File hashes

Hashes for simple_slack_logger-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f0e1120499d0cde7b672ef3adf19a97b6ed67c348dc6eb464d7f689e0b742fa
MD5 120d12a8ea0fa334fd023d936d73f23c
BLAKE2b-256 f997b1457d7683ca90101976ef885f7ebc82382acc0d7e3f3111328047b964e9

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