def add_file_handler(logger):
"""
Add a log handler that writes logs to a auto rotated file.
The file will be rotated every day.
:param logger:
:return:
"""
log_dir = 'log'
if not os.path.exists(log_dir):
os.mkdir(log_dir)
filename = os.path.join(log_dir, 'sigma.log')
handler = TimedRotatingFileHandler(filename, when='d', interval=1, encoding='utf-8', utc=True)
logger.add_handler(handler)
评论列表
文章目录