Python Slack log handler using webhook

claudetech claudetech Last update: Aug 20, 2020

Python Slack log handler

Simple Python log handler for Slack using Slack webhooks.

Installation

$ pip install slack_log_handler

Usage

The only required argument for SlackLogHandler is the webhook URL.You can pass the channel, username, or a dictionary of emojis for eachlog level as named arguments.

Sample usage:

import osimport loggingfrom slack_log_handler import SlackLogHandlerWEBHOOK_URL = os.getenv('SLACK_URL')slack_handler = SlackLogHandler(WEBHOOK_URL)slack_handler.setLevel(logging.WARNING)logger = logging.getLogger(__name__)logger.addHandler(slack_handler)logger.error('Oh my god, an error occurred!')

Troubleshooting

On Linux, if you get an error of this kind,

SSL: CERTIFICATE_VERIFY_FAILED

make sure the ca-certificates package (or whatever package your distribution uses instead) is installed.

Tags:

PRAGMA foreign_keys = off; BEGIN TRANSACTION; COMMIT TRANSACTION; PRAGMA foreign_keys = on;

Subscribe to our newsletter