Skip to main content

Logging to Slack, made easy.

Project description

SlackPush - Logging to Slack made easy

SlackPush provides a wrapper on requests to push messages, logs, exceptions and attachments to slack. It also supports basic formating: Bold and Perforated.

Installation

To get started, clone the repository and run

pip install slackpush

Usage

  1. Import the SlackPush object.

from slackpush import SlackPush

  1. Initialise SlackPush object with a webhook_url and channel to be posted in. To know more about incoming webhooks read here.

slackpush = SlackPush(webhook_url= <your webhook_url>, channel=<your channel>)

  1. Push messages/ logs using send_message method.

slackpush.send_message('It is up and running')

  1. Similarly you can push specific exceptions as alerts to slack using send_exception method. This pushes the whole stack trace of the error to slack.
try:
    < your code here>
except Exception as e:
    slackpush.send_exception(e)
  1. To send attachments to slack, you need to pass Slack OAuth token. More details can be found here.

Note: See that the token has relevant persmissions to post the attachement

To add token to the object use add_token method. To send an attachment to Slack:

slackpush.send_attachment(<path to attachment>)

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for slackpush, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size slackpush-0.1.1-py2.py3-none-any.whl (4.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size slackpush-0.1.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page