Skip to main content

log handler for send message to dingtalk

Project description

钉钉群告警Handler

通过钉钉群机器人, 发送Python日志到钉钉群

参考钉钉群机器人接口 https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq/26eaddd5

打包

python setup.py sdist

使用示例

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.

Files for dingtalk-log-handler, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size dingtalk_log_handler-0.0.3-py3-none-any.whl (7.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dingtalk-log-handler-0.0.3.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page