Skip to content

Commit

Permalink
捕获消息日志
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Jul 31, 2018
1 parent 7323c81 commit 84a15e9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions sql/notify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: UTF-8 -*-
import datetime
import traceback
from threading import Thread

from django.contrib.auth.models import Group
Expand Down Expand Up @@ -125,18 +126,20 @@ def _send(audit_id, msg_type, **kwargs):
msg_email_cc = [msg_email_cc]

# 判断是发送钉钉还是发送邮件
if msg_type == 0:
if sys_config.get('mail') == 'true':
msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc)
if sys_config.get('ding') == 'true':
msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content)
if msg_type == 1:
if sys_config.get('mail') == 'true':
msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc)
elif msg_type == 2:
if sys_config.get('ding') == 'true':
msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content)

try:
if msg_type == 0:
if sys_config.get('mail') == 'true':
msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc)
if sys_config.get('ding') == 'true':
msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content)
if msg_type == 1:
if sys_config.get('mail') == 'true':
msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc)
elif msg_type == 2:
if sys_config.get('ding') == 'true':
msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content)
except Exception:
logger.error(traceback.format_exc())

# 异步调用
def send_msg(audit_id, msg_type, **kwargs):
Expand Down

0 comments on commit 84a15e9

Please sign in to comment.