Ver Fonte

Added config option to change what module logs should be outputted

Kristian Vos há 4 anos atrás
pai
commit
c5b953cefa
3 ficheiros alterados com 26 adições e 19 exclusões
  1. 16 1
      backend/config/template.json
  2. 9 0
      backend/core.js
  3. 1 18
      backend/index.js

+ 16 - 1
backend/config/template.json

@@ -55,5 +55,20 @@
 		"stationIssue": false,
 		"traceUnhandledPromises": false,
 		"captureJobs": []
-	}
+	},
+	"defaultLogging": {
+        "hideType": [
+            "INFO"
+        ],
+        "blacklistedTerms": [
+        ]
+    },
+    "customLoggingPerModule": {
+        // "cache": {
+        //     "hideType": [
+
+        //     ],
+        //     "blacklistedTerms": []
+        // }
+    }
 }

+ 9 - 0
backend/core.js

@@ -294,6 +294,10 @@ export default class CoreClass {
 		this.stage = 0;
 		this.jobStatistics = {};
 
+		this.logRules = config.get("customLoggingPerModule")[name]
+			? config.get("customLoggingPerModule")[name]
+			: config.get("defaultLogging");
+
 		this.registerJobs();
 	}
 
@@ -368,11 +372,16 @@ export default class CoreClass {
 			return;
 		}
 
+		if (this.logRules.hideType.indexOf(type) !== -1) return;
+
 		_arguments.splice(0, 1);
 		const start = `|${this.name.toUpperCase()}|`;
 		const numberOfSpacesNeeded = 20 - start.length;
 		_arguments.unshift(`${start}${Array(numberOfSpacesNeeded).join(" ")}`);
 
+		if (this.logRules.blacklistedTerms.some(blacklistedTerm => _arguments.join().indexOf(blacklistedTerm) !== -1))
+			return;
+
 		if (type === "INFO") {
 			_arguments[0] += "\x1b[36m";
 			_arguments.push("\x1b[0m");

+ 1 - 18
backend/index.js

@@ -14,24 +14,7 @@ process.on("uncaughtException", err => {
 });
 
 const blacklistedConsoleLogs = [
-	"Running job IO",
-	"Ran job IO successfully",
-	"Running job HGET",
-	"Ran job HGET successfully",
-	"Running job HGETALL",
-	"Ran job HGETALL successfully",
-	"Running job GET_ERROR",
-	"Ran job GET_ERROR successfully",
-	"Running job GET_SCHEMA",
-	"Ran job GET_SCHEMA successfully",
-	"Running job SUB",
-	"Ran job SUB successfully",
-	"Running job GET_MODEL",
-	"Ran job GET_MODEL successfully",
-	"Running job HSET",
-	"Ran job HSET successfully",
-	"Running job CAN_USER_VIEW_STATION",
-	"Ran job CAN_USER_VIEW_STATION successfully"
+	
 ];
 
 const oldConsole = {};