Browse Source

获取日志存在bug ,正在排查~~~

hl 9 months ago
parent
commit
b0ca46e8d3
2 changed files with 18 additions and 18 deletions
  1. 16 16
      src/utils/file.js
  2. 2 2
      src/web.js

+ 16 - 16
src/utils/file.js

@@ -102,27 +102,27 @@ function getLastFile(dirPath, number, callback) {
             let fileList = [];
             //提示日志默认是根据日志生成的,拿到的files 也是 按照生成日志排序的,所以
             // 按照倒叙获取,如果一个文件内容满足num,就不在继续查询,如果不够,继续获取文件
-            for (var i = files.length - 1; i >= 0; i--) {
-                var file = files[i];
-                logger.info(`--------02..00`, dirPath, file,i,files.length)
-                const filePath = path.join(dirPath, file);
-                const stats = await fs.promises.stat(filePath);
-                fileList.push({name: file, time: stats.mtimeMs});
-
-                if (fileList.length > number) {//如果够 number 就不再继续获取文件
-                    break
-                }
-            }
-
-            // for (file of files) {
-            //
+            // for (var i = files.length - 1; i >= 0; i--) {
+            //     var file = files[i];
+            //     logger.info(`--------02..00`, dirPath, file,i,files.length,fileList.length)
             //     const filePath = path.join(dirPath, file);
-            //     logger.info(`--------02..111`, filePath)
             //     const stats = await fs.promises.stat(filePath);
-            //     logger.info(`--------02..22222`, stats)
             //     fileList.push({name: file, time: stats.mtimeMs});
+            //
+            //     if (fileList.length > number) {//如果够 number 就不再继续获取文件
+            //         break
+            //     }
             // }
 
+            for (file of files) {
+                logger.info(`--------02..00`, dirPath, file,files.length,fileList.length)
+                const filePath = path.join(dirPath, file);
+                logger.info(`--------02..111`, filePath)
+                const stats = await fs.promises.stat(filePath);
+                logger.info(`--------02..22222`, stats)
+                fileList.push({name: file, time: stats.mtimeMs});
+            }
+
             logger.info(`--------03`)
             fileList.sort((a, b) => b.time - a.time);
             logger.info(`--------04`)

+ 2 - 2
src/web.js

@@ -28,7 +28,7 @@ function init() {
             var md5 = req.headers.catilla
             //默认32位
             const md5Str = crypto.createHash('md5').update(k + timestamp).digest('hex');
-            // logger.info(JSON.stringify(md5Str))
+            logger.info(JSON.stringify(md5Str))
             if (md5 === md5Str) {
                 next();
             } else {
@@ -83,7 +83,7 @@ function init() {
         const n = param.n
         const id = param.id
 
-        var port = -1;
+        var port = 1111;
         robot.appMap.forEach((value, key) => {
             // logger.info(JSON.stringify(value))
             if (value.id + "" === id + "") {