mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-27 06:59:54 +08:00
新增 日志分离功能
This commit is contained in:
parent
e21a37c645
commit
0d31ed17a8
@ -23,11 +23,14 @@ import fs from "fs-extra";
|
||||
import log4js from "log4js";
|
||||
|
||||
const LOG_FILE_PATH = "logs/current.log";
|
||||
const DEBUG = true;
|
||||
|
||||
// 每次启动时将日志文件单独保存
|
||||
if (fs.existsSync(LOG_FILE_PATH)) {
|
||||
const time = new Date().toLocaleDateString().replace(/\//gim, "-");
|
||||
fs.renameSync(LOG_FILE_PATH, `logs/${time}.log`);
|
||||
const time = new Date();
|
||||
const timeString = `${time.getFullYear()}-${
|
||||
time.getMonth() + 1
|
||||
}-${time.getDate()}_${time.getHours()}-${time.getMinutes()}-${time.getSeconds()}`;
|
||||
fs.renameSync(LOG_FILE_PATH, `logs/${timeString}.log`);
|
||||
}
|
||||
|
||||
log4js.configure({
|
||||
|
Loading…
Reference in New Issue
Block a user