[Fix]允许用户自定义日志输出文件的名称 #602

This commit is contained in:
vn.py 2017-12-02 23:16:06 +08:00
parent 05a58c24ba
commit bb678b6842

View File

@ -594,10 +594,11 @@ class LogEngine(object):
self.logger.addHandler(self.consoleHandler)
#----------------------------------------------------------------------
def addFileHandler(self):
def addFileHandler(self, filename=''):
"""添加文件输出"""
if not self.fileHandler:
filename = 'vt_' + datetime.now().strftime('%Y%m%d') + '.log'
if not filename:
filename = 'vt_' + datetime.now().strftime('%Y%m%d') + '.log'
filepath = getTempPath(filename)
self.fileHandler = logging.FileHandler(filepath)
self.fileHandler.setLevel(self.level)