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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for slack_exception_logger-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa35e8bf42de3650b188ace3e1621de7b8de6541c6c1ce98e7f59c3582031339 |
|
MD5 | b32ef049fefde2e6622692580f9d4432 |
|
BLAKE2b-256 | 2f3677508519874f5b9daf6ea6f718e1cb427a7071d88c9d50d6a29c13d079cf |
Hashes for slack_exception_logger-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad098e90b28468a0f8433645d42790f42dcb07579fac6b636255bf9b4c4a6c90 |
|
MD5 | bb662f36d481c30c2463dd4750f0f9ce |
|
BLAKE2b-256 | 2ff995db41a01e54370b8ee665597b843c87216fd5d7c40cc131b39daf7fdc1a |