写日志

import time
import nnlog
def write_log(content):
with open('text.log','a+',encoding='utf-8') as fw:
data = time.strftime('%Y-%m-%d %H:%M:%S')
s = '%s ,内容 %s'%(data,content)
print(s)
fw.write(s)


log = nnlog.Logger('test.log',level='debug',backCount=3,when='H')
log.debug('调试信息')
log.info('正常的打印信息')
log.warning('警告')
log.error('数据库连接错误!')

posted on 2019-06-27 16:44  静思的技术博客  阅读(117)  评论(0编辑  收藏  举报

导航