class logger(object):
def __init__(self):
if not os.path.exists(self.logPath):
os.mknod(self.logPath)
if os.path.getsize(self.logPath)>1024*1024:
os.rename(self.logPath,self.logPath+'.bk')
with open(self.logPath,'a') as f:
if withTime:
now = datetime.datetime.now()
f.write(now.strftime('%Y-%m-%d %H:%M:%S')+':\t'+logString)
else:
f.write(logString)
def __init__(self):
self.logPath=sys.path[0]+'/log.txt'
def __init__(self,logPath):
self.logPath=logPath
def writeLog(self,logString,withTime=True):if not os.path.exists(self.logPath):
os.mknod(self.logPath)
if os.path.getsize(self.logPath)>1024*1024:
os.rename(self.logPath,self.logPath+'.bk')
with open(self.logPath,'a') as f:
if withTime:
now = datetime.datetime.now()
f.write(now.strftime('%Y-%m-%d %H:%M:%S')+':\t'+logString)
else:
f.write(logString)