Is it possible to redirect logs from the built in logging module to a Slack channel, rather than stdout or a file.
I was thinking there might be some way to do this using the Slack API client:
import logging
from slackclient import SlackClient
slack_token = 'MY-TOKEN-HERE'
sc = SlackClient(slack_token)
logging.basicConfig(...)  # Some slack magic???
logging.debug('This message should go to a slack channel')
logging.info('So should this')
logging.warning('And this, too')
There is a package ‘slack-log-handler’ on PyPI.
It contains a ‘LogHandler’ which can be used by the python logging module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With