Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 8228804

Browse files
committed
新增 日志分离功能
1 parent 3130d34 commit 8228804

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/service/log.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@
1818
根据 AGPL 与用户协议,您必须保留所有版权声明,如果修改源代码则必须开源修改后的源代码。
1919
可以前往 https://mcsmanager.com/ 阅读用户协议,申请闭源开发授权等。
2020
*/
21-
21+
import fs from "fs-extra";
2222
import * as log4js from "log4js";
23+
2324
const LOG_FILE_PATH = "logs/current.log";
2425

26+
// 每次启动时将日志文件单独保存
27+
if (fs.existsSync(LOG_FILE_PATH)) {
28+
const time = new Date();
29+
const timeString = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}_${time.getHours()}-${time.getMinutes()}-${time.getSeconds()}`;
30+
fs.renameSync(LOG_FILE_PATH, `logs/${timeString}.log`);
31+
}
32+
2533
log4js.configure({
2634
appenders: {
2735
out: {

0 commit comments

Comments
 (0)