From bc2cf2ed74fa7142364efb6383920d30e9d786ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=88=E6=9E=97=E6=B5=B7?= Date: Tue, 28 Mar 2023 11:33:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 2 +- .idea/{EasyTest.iml => t2-api-autotest.iml} | 0 utils/log_control.py | 23 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) rename .idea/{EasyTest.iml => t2-api-autotest.iml} (100%) create mode 100644 utils/log_control.py diff --git a/.idea/modules.xml b/.idea/modules.xml index d262650..74b7f5f 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/EasyTest.iml b/.idea/t2-api-autotest.iml similarity index 100% rename from .idea/EasyTest.iml rename to .idea/t2-api-autotest.iml diff --git a/utils/log_control.py b/utils/log_control.py new file mode 100644 index 0000000..b7f47ee --- /dev/null +++ b/utils/log_control.py @@ -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() +