writeLog("hello") 然后直接在其他文件引用import myLog ,对于要写入的消息 用 myLog.writeLog('insert bad ') 写入 insert bad 的消息
writeLog("hello") 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 然后直接在其他文件引用import myLog ,对于要写入的消息 用 myLog.writeLog('insert bad ') 写入 insert bad 的消息 日常使用 # -*- coding:utf-8 -*- import os,sys, time import ...
import time class Log: def __init__(self): pass def WriteLog(self,message,flag = False): strMessage = '\n' + time.strftime('%Y-%m-%d %H:%M:%S') if flag: strMessage += ': %s' % message else: strMessage += ':\n%s' % message fileName = os.path.join(os.getcwd(), time....
self.logger.addHandler(fh)defWriteLog(self,message): self.logger.info(message)defWriteErrorLog(self,message): self.logger.setLevel(logging.ERROR) self.logger.error(message) 2、自己写日志 importosimporttimeclassLog:def__init__(self):passdefWriteLog(self,message,flag =False): strMessage='\n'+...
util.WriteLog('api').info('123') index() ''' 4:logging.basicConfig([**kwargs])——加载logger的各项配置参数,不好用 cat test.py import logging logging.basicConfig(level=logging.DEBUG,#输出debug及其级别更高级别的日志 format='%(asctime)s %(filename)s [line:%(lineno)d] %(levelname)s ...
def BarItemClick(e): #按钮1点击事件 if e.BarItemKey=="tbLog": message = this.Model.GetValue("FName") logObj =LogObject() logObj.pkValue ="1234" logObj.Description ="hhtest测试描述"+str(message) LogServiceHelper.WriteLog(this.Context, logObj)...
logger.addHandler(handler)returnlogger # 函数最终将实例化的logger对象返回,后面直接调用即可if__name__=="__main__":WriteLog('api').info('123')# 模块内部直接调用函数。等价下面两行 # 下面的方法不推荐 # writelog=WriteLog('api')# writelog.info('123') ...
write("\n") # 文件条数计数器 Parse_MySQL_Slow_Log.sql_count += 1 logger_info.info("sql count:" + str(Parse_MySQL_Slow_Log.sql_count)) else: file_handler.write(data) def parse_log(self): with open(self.slowlog, encoding="utf8") as f: tmp_list = [] flag = 0 flag_word ...
_ctx->writeLog("No lastest tick data of %s, execute later", _code.c_str()); return; } if (decimal::eq(curPos, newVol)) { //当前仓位和最新仓位匹配时,如果不是全部清仓的需求,则直接退出计算了 if (!is_clear(_target_pos)) return; ...
log.OperateName = "分组全路径节点修复"; log.ObjectTypeId = formId; log.Environment = OperatingEnvironment.BizOperate; log.Description = info; log.pkValue = ""; LogServiceHelper.WriteLog(this.Context, log); #根据根节点循环查找所有子节点(修复检测) ...