mirror of https://github.com/Mai-with-u/MaiBot.git
Sink logs to logs file
parent
aecb4ffa35
commit
8676682e97
|
|
@ -3,6 +3,7 @@ data1/
|
||||||
mongodb/
|
mongodb/
|
||||||
NapCat.Framework.Windows.Once/
|
NapCat.Framework.Windows.Once/
|
||||||
log/
|
log/
|
||||||
|
logs/
|
||||||
/test
|
/test
|
||||||
/src/test
|
/src/test
|
||||||
message_queue_content.txt
|
message_queue_content.txt
|
||||||
|
|
|
||||||
13
bot.py
13
bot.py
|
|
@ -17,6 +17,19 @@ env_mask = {key: os.getenv(key) for key in os.environ}
|
||||||
|
|
||||||
uvicorn_server = None
|
uvicorn_server = None
|
||||||
|
|
||||||
|
# 配置日志
|
||||||
|
log_path = os.path.join(os.getcwd(), "logs")
|
||||||
|
if not os.path.exists(log_path):
|
||||||
|
os.makedirs(log_path)
|
||||||
|
|
||||||
|
# 添加文件日志,启用rotation和retention
|
||||||
|
logger.add(
|
||||||
|
os.path.join(log_path, "maimbot_{time:YYYY-MM-DD}.log"),
|
||||||
|
rotation="00:00", # 每天0点创建新文件
|
||||||
|
retention="30 days", # 保留30天的日志
|
||||||
|
level="INFO",
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
def easter_egg():
|
def easter_egg():
|
||||||
# 彩蛋
|
# 彩蛋
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue