Skip to main content

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

dingtalk-log-handler-0.0.6.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

dingtalk_log_handler-0.0.6-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file dingtalk-log-handler-0.0.6.tar.gz.

File metadata

  • Download URL: dingtalk-log-handler-0.0.6.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.28.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

File hashes

Hashes for dingtalk-log-handler-0.0.6.tar.gz
Algorithm Hash digest
SHA256 35fcf75002bc79b6e2d234ece983be5ba2e71c3c54c3f774cc12b3745b470338
MD5 9d3d75a049ac5cce78077c2605d5f5db
BLAKE2b-256 87cf52aea96ea640b347c3e463a0871f0c4e495808eb5f963d43157153ccc268

See more details on using hashes here.

File details

Details for the file dingtalk_log_handler-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: dingtalk_log_handler-0.0.6-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.8.1 pkginfo/1.7.1 requests/2.28.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

File hashes

Hashes for dingtalk_log_handler-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 797506b2a627a42039827202609bb1dfb0a2eb31125b92c05b781e51ef15807a
MD5 11d6c1bca3458f0fac3622a63bd31c26
BLAKE2b-256 e4fc308b572a69124796a68afb31634b832a26672a8829e6fe2a66781ed3d0fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page