loguru

loguru

比 logging 更加轻便简单的日志记录器

基本使用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from loguru import logger
import os
import time

LOG_FOLDER = os.getcwd()+'\\logs'
if not os.path.exists(LOG_FOLDER):
    os.mkdir(LOG_FOLDER)
    t = time.strftime("%Y_%m_%d")
    logger = logger
    logger.add("{}\\log_{}.log".format(LOG_FOLDER, t),
               rotation="00:00", encoding="utf-8", retention="300 days")