瀏覽代碼

as 调整

hl 8 月之前
父節點
當前提交
475094a9c3
共有 2 個文件被更改,包括 10 次插入5 次删除
  1. 9 4
      src/utils/file.js
  2. 1 1
      src/web.js

+ 9 - 4
src/utils/file.js

@@ -103,11 +103,14 @@ function getLastFile(dirPath, number, callback) {
             for (file of files) {
                 const filePath = path.join(dirPath, file);
                 const stats = await fs.promises.stat(filePath);
-                fileList.push({name: file, time: stats.mtimeMs});
-                // logger.info("文件:" +filePath+"时间:"+stats.birthtime.getTime())
+                fileList.push({name: file, time: stats.birthtime.getTime()});
+                // logger.info("文件:" + filePath + "时间:" + stats.birthtime.getTime())
             }
 
             fileList.sort((a, b) => b.time - a.time);
+            // for (a of fileList) {
+            //     logger.info("文件cccccccc22222222:" + a.name + "\ttime:" + a.time)
+            // }
             lastFileList = fileList.slice(0, number != -1 ? number : fileList.length);
             lastFileNameList = lastFileList.map((item) => item.name);
 
@@ -119,7 +122,10 @@ function getLastFile(dirPath, number, callback) {
 // 读取日志(倒叙)指定行数
 function readLastNLines(dirPath, filePathList, n) {
     try {
-
+        // for (var i = 0; i < filePathList.length; i++) {
+        //     var item = filePathList[i];
+        //     logger.info("日志文件2222222:" + item)
+        // }
 
         const fileList = [];
         var count = 0;
@@ -147,7 +153,6 @@ function readLastNLines(dirPath, filePathList, n) {
         return lastNLines.split("\n").reverse();
     } catch (e) {
         logger.info('获取日志异常了~~1111111111111111', e);
-
     }
 }
 

+ 1 - 1
src/web.js

@@ -90,7 +90,7 @@ function init() {
             try {
                 file.checkPathSync(directoryPath)
 
-                file.getLastFile(logPath, 10, (fileNameList,_) => {
+                file.getLastFile(logPath, 5, (fileNameList,_) => {
                     // logger.info('文件:', fileNameList);
                     result = file.readLastNLines(logPath, fileNameList, n);
                     // logger.info('?????:', result);