def writeNotification(self, content): """快速发出通知日志事件""" log = VtLogData() log.logContent = content event = vn_event(type_=EVENT_NOTIFICATION) event.dict_['data'] = log self.eventEngine.put(event) # 发出邮件 if globalSetting.get('activate_email', False): try: sendmail(subject=u'{0} Notification'.format('_'.join( self.connected_gw_names)), msgcontent=content) except Exception as ex: print( u'vtEngine.writeNotification sendmail Exception:{}'.format( str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr) # 发出微信 if globalSetting.get('activate_wx_ft', False): try: from huafu.util.util_wx_ft import sendWxMsg sendWxMsg(text=content) except Exception as ex: print(u'vtEngine.writeNotification sendWxMsg Exception:{}'. format(str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr)
def writeCritical(self, content): """快速发出严重错误日志事件""" log = VtLogData() log.logContent = content event = vn_event(type_=EVENT_CRITICAL) event.dict_['data'] = log self.eventEngine.put(event) print('{}'.format(datetime.now()), file=sys.stderr) print(content, file=sys.stderr) # 写入本地log日志 if self.logger: self.logger.critical(content) else: self.createLogger() # 发出邮件 if globalSetting.get('activate_email',False): # 发出邮件 try: sendmail(subject=u'{0} Critical'.format('_'.join(self.connected_gw_names)), msgcontent=content) except Exception as ex: print(u'vtEngine.writeCritical sendmail Exception:{}'.format(str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr) # 发出微信 if globalSetting.get('activate_wx_ft',False): try: from huafu.util.util_wx_ft import sendWxMsg sendWxMsg(text=content) except Exception as ex: print(u'vtEngine.writeCritical sendWxMsg Exception:{}'.format(str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr)
def writeError(self, content): """快速发出错误日志事件""" log = VtErrorData() log.errorMsg = content event = vn_event(type_=EVENT_ERROR) event.dict_['data'] = log self.eventEngine.put(event) # 写入本地log日志 if self.logger is not None: self.logger.error(content) else: self.createLogger() # 发出邮件 if globalSetting.get('activate_email', False): try: sendmail(subject=u'{0} Error'.format('_'.join( self.connected_gw_names)), msgcontent=content) except Exception as ex: print(u'vtEngine.writeError sendmail Exception:{}'.format( str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr) # 发出微信 if globalSetting.get('activate_wx_ft', False): try: from huafu.util.util_wx_ft import sendWxMsg sendWxMsg(text=content) except Exception as ex: print(u'vtEngine.writeError sendWxMsg Exception:{}'.format( str(ex)), file=sys.stderr) print(u'{}'.format(traceback.format_exc()), file=sys.stderr)