赞
踩
- # 写日志
- def logger(text, title='Base',consolewrite=False):
- """
- 写日志
- :text: text日志内容
- :title: 模块标识
- :consolewrite: 是否控制台输出
- """
- filename = os.getcwd() + r'\log\OperationLogs\%s.log' % get_now_time(6)
- i = 1
- isbig = True
- while isbig:
- if not os.path.exists(filename):
- newf = open(filename, 'w')
- newf.close()
- filesize = os.path.getsize(filename)
- if filesize > 3 * 1024 * 1024:
- filename = os.getcwd() + r'\log\OperationLogs\%s_%s.log' % (get_now_time(6), i)
- else:
- isbig = False
- i += 1
- strline = "【%s】【%s】%s\n" % (title, get_now_time(1), text)
- if consolewrite:
- print(strline)
- with open(filename, "a") as f:
- f.write(strline)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。