瀏覽代碼

Added more debugging for station-skip issue

Kristian Vos 4 年之前
父節點
當前提交
fb5b8b1b05
共有 3 個文件被更改,包括 34 次插入0 次删除
  1. 17 0
      backend/core.js
  2. 7 0
      backend/index.js
  3. 10 0
      backend/logic/api.js

+ 17 - 0
backend/core.js

@@ -1,4 +1,5 @@
 const async = require("async");
+const config = require("config");
 
 class DeferredPromise {
     constructor() {
@@ -86,6 +87,12 @@ class CoreClass {
     log() {
         let _arguments = Array.from(arguments);
         const type = _arguments[0];
+
+        if (config.debug && config.debug.stationIssue === true && type === "STATION_ISSUE") {
+            this.moduleManager.debugLogs.stationIssue.push(_arguments);
+            return;
+        }
+
         _arguments.splice(0, 1);
         const start = `|${this.name.toUpperCase()}|`;
         const numberOfTabsNeeded = 4 - Math.ceil(start.length / 8);
@@ -131,6 +138,10 @@ class CoreClass {
         let deferredPromise = new DeferredPromise();
         const job = { name, payload, onFinish: deferredPromise };
 
+        if (config.debug && config.debug.stationIssue === true && config.debug.captureJobs && config.debug.captureJobs.indexOf(name) !== -1) {
+            this.moduleManager.debugJobs.stationIssue.all.push(job);
+        }
+
         if (options.bypassQueue) {
             this._runJob(job, () => {});
         } else {
@@ -163,11 +174,17 @@ class CoreClass {
             .then((response) => {
                 this.log("INFO", `Ran job ${job.name} successfully`);
                 this.jobStatistics[job.name].successful++;
+                if (config.debug && config.debug.stationIssue === true && config.debug.captureJobs && config.debug.captureJobs.indexOf(job.name) !== -1) {
+                    this.moduleManager.debugJobs.stationIssue.completed.push({ status: "success", job, response });
+                }
                 job.onFinish.resolve(response);
             })
             .catch((error) => {
                 this.log("INFO", `Running job ${job.name} failed`);
                 this.jobStatistics[job.name].failed++;
+                if (config.debug && config.debug.stationIssue === true && config.debug.captureJobs && config.debug.captureJobs.indexOf(job.name) !== -1) {
+                    this.moduleManager.debugJobs.stationIssue.completed.push({ status: "error", job, error });
+                }
                 job.onFinish.reject(error);
             })
             .finally(() => {

+ 7 - 0
backend/index.js

@@ -235,6 +235,13 @@ class ModuleManager {
         this.i = 0;
         this.lockdown = false;
         this.fancyConsole = fancyConsole;
+        this.debugLogs = {
+            stationIssue: []
+        };
+        this.debugJobs = {
+            all: [],
+            completed: []
+        };
     }
 
     addModule(moduleName) {

+ 10 - 0
backend/logic/api.js

@@ -90,6 +90,16 @@ class APIModule extends CoreClass {
                                         next(err);
                                     })
                                 }, next);
+                            },
+
+                            next => {
+                                responseObject.debugLogs = this.moduleManager.debugLogs.stationIssue;
+                                next();
+                            },
+
+                            next => {
+                                responseObject.debugJobs = this.moduleManager.debugJobs;
+                                next();
                             }
                         ], (err, response) => {
                             if (err) {