新增日志记录

This commit is contained in:
谈林海 2023-03-28 11:33:52 +08:00
parent bca4ee4e05
commit bc2cf2ed74
3 changed files with 24 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/EasyTest.iml" filepath="$PROJECT_DIR$/.idea/EasyTest.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/t2-api-autotest.iml" filepath="$PROJECT_DIR$/.idea/t2-api-autotest.iml" />
</modules>
</component>
</project>

23
utils/log_control.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023/3/28 11:24
# @Author : 谈林海
import time
import loguru
from utils.path import root
log_path = root / 'logs'
class Loggings:
"""重写日志操作方法"""
def __new__(cls, *args, **kwargs):
loggers = loguru.logger
loggers.add(f"{log_path}/log_{time.strftime('%Y_%m_%d')}.log", rotation="12:00", encoding="utf-8",
enqueue=True, retention="10 days")
return loggers
logger = Loggings()