log handler for send message to dingtalk
Project description
钉钉群告警Handler
通过钉钉群机器人, 发送Python日志到钉钉群
参考钉钉群机器人接口 https://open.dingtalk.com/document/robots/custom-robot-access
安装
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
Built Distribution
File details
Details for the file dingtalk-log-handler-0.0.7.tar.gz
.
File metadata
- Download URL: dingtalk-log-handler-0.0.7.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04aa31c53afe17d6941c845632367e5b5a0ef51c860e053033e7f50c428fd2d4 |
|
MD5 | 4798bcf3c8c962d5e66160d6ebf27e22 |
|
BLAKE2b-256 | 2652f8df08a24e1a71c421b1753a6f1a607f8ab6a0da04acebe643f1f895f240 |
File details
Details for the file dingtalk_log_handler-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: dingtalk_log_handler-0.0.7-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c832e22690ac2a0a40c25e6838983f9f86834e76a2a3471e40cb10f7c939e2d9 |
|
MD5 | b4a3bafc01b286358c4dd0a0bd8994f5 |
|
BLAKE2b-256 | ed15334955aff040330e5e74ae3d8fbc3f5fee9a5ea4072fb27576d2ee13efa7 |