Skip to main content

A Python library for logging exceptions to a Slack channel

Project description

slack_exception_logger

A Python library that allows you to log exceptions to a Slack channel using the Slack Webhook API.

Installation

You can install slack_exception_logger using pip:

pip install slack_exception_logger

Usage

To use slack_exception_logger, you need to import the push_to_slack function from the library:

from slack_exception_logger import push_to_slack

You can then call the push_to_slack function and pass the exception object as an argument whenever an exception occurs in your code:

try:
    # Your code that may throw an exception
    1/0
except Exception as e:
    push_to_slack(e)

Before using the library, you need to set the following environment variables:

SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services/your-webhook-url'
SLACK_CHANNEL = '#exceptions'

You can get the Webhook URL by creating an incoming webhook in your Slack workspace.

Note

This library uses the traceback module to get the complete exception details, which includes the exception type, value, and the stack trace, and then sends the traceback information to the slack channel. It is also possible to filter out the sensitive information from the traceback before sending it to slack.

License

This library is licensed under the MIT License.

Contribution

We welcome contributions to this library. If you have an idea for a new feature or have found a bug, please open an issue on Github.

Buy me a Coffee

ko-fi

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

slack_exception_logger-0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

slack_exception_logger-0.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

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