Skip to content

Commit 512ac2d

Browse files
committed
log改为按启动日期进行存储
1 parent 8afa814 commit 512ac2d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import threading
44
from loguru import logger
5+
from datetime import datetime
56

67
from graia.ariadne.event.lifecycle import ApplicationLaunched
78
from graia.ariadne.event.message import Group, Member, MessageChain, Friend
@@ -18,14 +19,17 @@
1819
saya = core.get_saya()
1920
config = core.get_config()
2021

22+
if not os.path.exists(f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}"):
23+
os.mkdir(f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}")
24+
2125
logger.add(
22-
f"{os.getcwd()}/log/common.log",
26+
f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}/common.log",
2327
level="INFO",
2428
retention=f"{config.log_related['common_retention']} days",
2529
encoding="utf-8"
2630
)
2731
logger.add(
28-
f"{os.getcwd()}/log/error.log",
32+
f"{os.getcwd()}/log/{datetime.now().strftime('%Y-%m-%d')}/error.log",
2933
level="ERROR",
3034
retention=f"{config.log_related['error_retention']} days",
3135
encoding="utf-8"

0 commit comments

Comments
 (0)