From 512ac2db8ec7128f6fe1191d6800b5b50cd98676 Mon Sep 17 00:00:00 2001 From: SAGIRI-kawaii Date: Tue, 26 Apr 2022 11:56:59 +0800 Subject: [PATCH] =?UTF-8?q?log=E6=94=B9=E4=B8=BA=E6=8C=89=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=A5=E6=9C=9F=E8=BF=9B=E8=A1=8C=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 7a780136..337395c8 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import os import threading from loguru import logger +from datetime import datetime from graia.ariadne.event.lifecycle import ApplicationLaunched from graia.ariadne.event.message import Group, Member, MessageChain, Friend @@ -18,14 +19,17 @@ saya = core.get_saya() config = core.get_config() +if not os.path.exists(f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}"): + os.mkdir(f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}") + logger.add( - f"{os.getcwd()}/log/common.log", + f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}/common.log", level="INFO", retention=f"{config.log_related['common_retention']} days", encoding="utf-8" ) logger.add( - f"{os.getcwd()}/log/error.log", + f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}/error.log", level="ERROR", retention=f"{config.log_related['error_retention']} days", encoding="utf-8"