From 5dc71ad46e14f0b170dfad5dea094deb3a509ba8 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 4 Jan 2018 18:50:09 +0100 Subject: [PATCH] Setting to reduce verbosity of logs (don't log item transfers) --- client.js | 10 +++++++--- config.json | 3 ++- master.js | 13 +++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/client.js b/client.js index 91e9ad9e..e6853220 100644 --- a/client.js +++ b/client.js @@ -684,7 +684,9 @@ function instanceManagement() { instanceID: instanceconfig.unique, // a hash computed from the randomly generated rcon password }, function (err, resp, body) { if(body == "failure") console.error("#### Export failed! Lost: "+g[1]+" "+g[0]); - if(body == "success") console.log(`Exported ${g[1]} ${g[0]} to master`) + if(config.logItemTransfers){ + if(body == "success") console.log(`Exported ${g[1]} ${g[0]} to master`); + } }); } } @@ -741,9 +743,11 @@ function instanceManagement() { if (response && response.body && typeof response.body == "object") { // buffer confirmed orders confirmedOrders[confirmedOrders.length] = { - [response.body.name]: response.body.count + [response.body.name]: response.body.count; + } + if(config.logItemTransfers){ + console.log(`Imported ${response.body.count} ${response.body.name} from master`); } - console.log(`Imported ${response.body.count} ${response.body.name} from master`); } }); } diff --git a/config.json b/config.json index 11643921..dde9c633 100644 --- a/config.json +++ b/config.json @@ -28,5 +28,6 @@ "itemStats": { "maxEntries":60, "entriesPerSecond": 0.01666666667 - } + }, + "logItemTransfers": false } diff --git a/master.js b/master.js index 874e619a..695d3f9c 100644 --- a/master.js +++ b/master.js @@ -270,8 +270,9 @@ app.post("/api/place", function(req, res) { && x.instanceName && !isNaN(Number(x.count))// This is in no way a proper authentication or anything, its just to make sure everybody are registered as slaves before modifying the cluster (or not, to maintain backwards compat) /*&& stringUtils.hashCode(slaves[x.unique].rconPassword) == x.unique*/){ - - console.log("added: " + req.body.name + " " + req.body.count+" from "+x.instanceName+" ("+x.instanceID+")"); + if(config.logItemTransfers){ + console.log("added: " + req.body.name + " " + req.body.count+" from "+x.instanceName+" ("+x.instanceID+")"); + } // gather statistics let recievedItemStatistics = recievedItemStatisticsBySlaveID[x.instanceID]; if(recievedItemStatistics === undefined){ @@ -326,7 +327,9 @@ app.post("/api/remove", function(req, res) { let item = db.items[object.name] // console.dir(doc); if (!item) { - console.log('failure could not find ' + object.name); + if(config.logItemTransfers){ + console.log('failure could not find ' + object.name); + } res.send({name:object.name, count:0}); } else { const originalCount = Number(object.count) || 0; @@ -338,7 +341,9 @@ app.post("/api/remove", function(req, res) { if(Number(item) > Number(object.count)) { //If successful, increase dole _doleDivisionFactor[object.name] = Math.max((_doleDivisionFactor[object.name]||0)||1, 1) - 1; - //console.log("removed: " + object.name + " " + object.count + " . " + item + " and sent to " + object.instanceID + " | " + object.instanceName); + if(config.logItemTransfers){ + console.log("removed: " + object.name + " " + object.count + " . " + item + " and sent to " + object.instanceID + " | " + object.instanceName); + } if(db.items.removeItem({count: object.count, name: object.name})){ let sentItemStatistics = sentItemStatisticsBySlaveID[object.instanceID]; if(sentItemStatistics === undefined){