Ver código fonte

将日志 与 机器人状态详情进行缓存,

hl 3 semanas atrás
pai
commit
df112098f4
2 arquivos alterados com 7 adições e 7 exclusões
  1. 1 1
      src/Interval.js
  2. 6 6
      src/utils/file.js

+ 1 - 1
src/Interval.js

@@ -111,7 +111,7 @@ function cacheLogs() {
                     logger.info(`访问-日志相对目录:${logPath}`)
                     const directoryPath = path.resolve(logPath);
                     file.checkPathSync(directoryPath)
-                    file.getLastFile(logPath, 5, (fileNameList, _) => {
+                    file.getLastFile(logPath, 3, (fileNameList, _) => {
                         logger.info('-----文件:', fileNameList);
                         file.getLatestLogEntries(logPath, fileNameList.reverse(), n)
                             .then((result) => {

+ 6 - 6
src/utils/file.js

@@ -107,7 +107,7 @@ function getLastFile(dirPath, number, callback) {
                     if (stats.isFile()) {
                         let tt = stats.birthtime.getTime();
                         fileList.push({name: file, time: tt});
-                        logger.info("----------------所有文件:" + filePath + "时间:" + tt);
+                        // logger.info("----------------所有文件:" + filePath + "时间:" + tt);
                     }
                 });
             });
@@ -125,16 +125,16 @@ function getLastFile(dirPath, number, callback) {
 
             // 等待所有的 Promise 完成
             Promise.all(filePromises).then(() => {
-                for (a of fileList) {
-                    const filePath = path.join(dirPath, a.name);
-                    logger.info("复查:" + filePath + "\ttime:" + a.time)
-                }
+                // for (a of fileList) {
+                //     const filePath = path.join(dirPath, a.name);
+                //     logger.info("复查:" + filePath + "\ttime:" + a.time)
+                // }
 
 
                 fileList.sort((a, b) => b.time - a.time);
                 for (a of fileList) {
                     const filePath = path.join(dirPath, a.name);
-                    logger.info("排序:" + filePath + "\ttime:" + a.time)
+                    // logger.info("排序:" + filePath + "\ttime:" + a.time)
                 }
                 let lastFileList = fileList.slice(0, number != -1 ? number : fileList.length);
                 let lastFileNameList = lastFileList.map((item) => item.name);