def db(fmt, *args, **kwargs): try: if kwargs.has_key('hook'): args = tuple(map(kwargs['hook'], args)) if args: fmt = fmt % args myclog.db(fmt) except Exception as e: print(traceback.format_exc()) print(args) print(kwargs) raise e
def d(fmt, *args, **kwargs): try: if 'hook' in kwargs: args = tuple(map(kwargs['hook'], args)) if args: fmt = fmt.format(*args) myclog.db(fmt) except Exception as e: print(traceback.format_exc()) print(args) print(kwargs) raise e
def test_myclog(): import traceback import time import sys try: print('print dir(myclog):') print(dir(myclog)) e = myclog.setLogHeader("logprefix") if e: print('print e:') print(e) print('print e.message') print(e.message) myclog.setLogDir(".\\") myclog.setLogBufferSize(10240) myclog.setLogMaxLine(10240) myclog.setLogLevel("error") start = time.time() cnt = 0 while 1: myclog.trace("log:trace") myclog.db("log:debug") myclog.warn("log:warn") myclog.error("log:error") myclog.critical("log:critical") # 60 cnt = cnt + 1 MyLog.error("str:%s, int:%s", "abc", 1) #myclog.flush() if cnt == 100: # 60 byte * 100 < 10240, 分开两次写来测试是否使用到缓存 cnt = 0 time.sleep(3) end = time.time() #myclog.close() print(end - start) except: print(traceback.format_exc())