Skip to content

Commit

Permalink
log改为按启动日期进行存储
Browse files Browse the repository at this point in the history
  • Loading branch information
SAGIRI-kawaii committed Apr 26, 2022
1 parent 8afa814 commit 512ac2d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 512ac2d

Please # to comment.