log handler for send message to dingtalk
Project description
钉钉群告警Handler
通过钉钉群机器人, 发送Python日志到钉钉群
参考钉钉群机器人接口 https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq/26eaddd5
安装
pip install dingtalk-log-handler
打包
python setup.py sdist
参数
- webhook: webhook url for dingtalk open api
- keyword: allowed message keyword, default 'alarm'
- secret: secret for dingtalk open api
- hostname: hostname for identify machine, default local ip address
- timeout: http request timeout, default 1 second
- cert_verify: verify SSL certificates or not, default True
使用示例
import logging
import logging.config
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '[%(levelname)s %(asctime)s %(name)s %(funcName)s %(lineno)d %(process)d]\t%(message)s'
},
},
'handlers': {
'dingtalk':{
'class': 'dingtalk_log_handler.DingTalkHandler',
'webhook': 'https://oapi.dingtalk.com/robot/send?access_token=XXXXX',
# 'secret': '',
# 'keyword': '',
'formatter':'verbose',
'level': 'ERROR',
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'': {
'handlers': ['dingtalk', 'console'],
'level': 'INFO',
'propagate': False,
},
}
}
logging.config.dictConfig(LOGGING)
logging.error('testing')
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
Close
Hashes for dingtalk-log-handler-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13e7ea04fd1f567e4bf76f565cabe28e866082935ad578d8d700a35667f4ec56 |
|
MD5 | 941850f1caa242f35306effa7cb898ba |
|
BLAKE2b-256 | 870c6305db7423903d81f21857b88d152eaae5712a2fe3f813c747f00d41eafa |