A Python logging handler for Slack integration
Project description
Python logging handler for Slack web hook integration with simple configuration.
Installation
pip install slack-logger
Example
Simple
import logging
from slack_logger import SlackHandler, SlackFormatter
sh = SlackHandler('YOUR_WEB_HOOK_URL') # url is like 'https://hooks.slack.com/...'
sh.setFormatter(SlackFormatter())
logging.basicConfig(handlers=[sh])
logging.warning('warn message')
Using logger
import logging
from slack_logger import SlackHandler, SlackFormatter
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
sh = SlackHandler(username='logger', icon_emoji=':robot_face:', url='YOUR_WEB_HOOK_URL')
sh.setLevel(logging.DEBUG)
f = SlackFormatter()
sh.setFormatter(f)
logger.addHandler(sh)
logger.debug('debug message')
logger.info('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)
logger.info('info message') # Not posted to slack
logger.info('info message to slack', extra={'notify_slack': True}) # Posted to slack
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-logger-0.2.0.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file slack-logger-0.2.0.tar.gz
.
File metadata
- Download URL: slack-logger-0.2.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c847f5061b050206313dd1f185e6483b0ec60fddfa4245b94b0d0e5c1422f579 |
|
MD5 | aabc53fccf8c650ea5e22e6cbdd6448a |
|
BLAKE2b-256 | 94dc7ae14670d7f0a6ec87f6b3efadc82dac1de901a962e1b9a0e636e82bb471 |
File details
Details for the file slack_logger-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: slack_logger-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a3358846f5654b10c96b380c4938c413ab65d799ded4efa5f0d56985dc161bc |
|
MD5 | e7889a41480a4f97e881668f09edfeee |
|
BLAKE2b-256 | a0dc8d0ec9dffc92f51f66ec1cc10a0bc195c86451da971a253ac3c88a9810b8 |