Skip to main content

A Python logging handler for Slack integration

Project description

Python logging handler for Slack web hook integration with simple configuration.


pip install slack-logger



import logging
from slack_logger import SlackHandler, SlackFormatter

sh = SlackHandler('YOUR_WEB_HOOK_URL') # url is like ''
logging.warning('warn message')

Using logger

import logging
from slack_logger import SlackHandler, SlackFormatter

logger = logging.getLogger(__name__)

sh = SlackHandler(username='logger', icon_emoji=':robot_face:', url='YOUR_WEB_HOOK_URL')

f = SlackFormatter()

logger.debug('debug message')'info message')
logger.warn('warn message')
logger.error('error message')
logger.critical('critical message')

Using filter

You can also filter some messages only

from slack_logger import SlackLogFilter

sf = SlackLogFilter()
sh.addFilter(sf)'info message')  # Not posted to slack'info message to slack', extra={'notify_slack': True})  # Posted to slack

Mentioning someone

Use mention option to send message with mentioning someone:

sh = SlackHandler('YOUR_WEB_HOOK_URL', mention='U012ABC34')

You can find a member ID (e.g., U012ABC34) from user’s profile view.

Project details

Download files

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

Files for slack-logger, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size slack_logger-0.3.1-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page