Python logging handler which post to slack
Project description
Slack logger
This package provides a logging.Handler that will send message to a slack channel. Supports updated slack.WebClient API released in 2019.
Authorization
See https:://api.slack.com to for information on setting up app and get an authorization token. Only a "bot" token is required to use SlackHandler, however, the unittest is more comlete with a "user" token.
Limitations
How often messages can be sent is limited by slack. See https://api.slack.com/docs/rate-limits. By default, this handler only sends accumulated messages every 60 seconds. That can be adjusted by the optional update argument to SlackHandler.
Example
token = 'your token here'
channel = 'your channel name'
handler = SlackHandler(token, channel)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
example_logger = logging.getLogger("Test Logger")
example_logger.propagate = False
example_logger.addHandler(handler)
example_logger.setLevel(logging.INFO)
example_logger.info("Then shalt thou use Python three, no more, no less.")
...
# at end of program
handler.send_remaining()
Funding acknowledgment
This work supported by National Institutes of Health (NIH) / National Institute of General Medical Sciences (NIGMS), grant 1P41GM111135.
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
Built Distribution
Hashes for slack-webclient-logger-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25fd3303870ab676d13ef64bcb37573632e20d9edf082bf81674ccf9da33f8d6 |
|
MD5 | a90ddcc440d9eafb44c99f67c4f776fd |
|
BLAKE2b-256 | 81778e7ee8ef418ee9ae0e4925f09cbdc504e5cb61953b37030bd62b93cf1ef1 |
Hashes for slack_webclient_logger-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72ab88779c3c5835191f4938abd2478df37edde88a2b8d15a3deb483b568c30f |
|
MD5 | c43a7b63bf3e37044378899901852037 |
|
BLAKE2b-256 | 7859da9e56422791535cf1a8a153460224371641ffd60a9056079d2b084ab232 |