python-slack-logger
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
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.
Metadata
Release files for slack-logger 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slack_logger-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for slack_logger-0.3.1-py3-none-any.whl |
Release files / slack_logger-0.3.1-py3-none-any.whl
| Download URL | slack_logger-0.3.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1d55c5e6c79089bf938db39d4e33756cd0e63d1f8b1743c7a99cc0c3957757c
|
|
BLAKE2b-256 checksum How to use checksums |
763cb6cc4e51d8021a8c20b1b0213fa9eb9cc1fb48a42dcd7215cc01ce25c4ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for slack-logger 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.