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())
def setLogDir(log_dir='./'): myclog.setLogDir(log_dir)