使用python生成日志
-- coding: gb2312 --
import time
from common.mkdir import mkdir
class writeLog(object):
'''
写日志文件
'''
def writeLog(self,logPath,testCaseName,log):
self.mkdir = mkdir()
self.actPath = self.mkdir.mkdir(logPath)
currentTime = time.strftime('%Y-%m-%d %H-%M-%S',time.localtime(time.time()))
fname = self.actPath + "\"+currentTime+".log"
fobj = open(fname,'w')
date = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
fobj.writelines(u'用例名称:' + testCaseName +'\n'+
u'日期:'+ date +'\n'+
u'日志内容:'+log
)
fobj.close()