From 95a6ab88d089216a4afc852b1961a384d1e41c04 Mon Sep 17 00:00:00 2001 From: YourFriendlyNeighborhoodDealer <3167982-YourFriendlyNeighborhoodDealer@users.noreply.gitlab.com> Date: Thu, 22 Nov 2018 14:37:11 +0100 Subject: [PATCH] Looging look improvements --- actions.js | 30 ++++++++++++++++-------------- server.js | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/actions.js b/actions.js index 2abd8a0..6f29589 100755 --- a/actions.js +++ b/actions.js @@ -32,7 +32,7 @@ var logger = require('./logger.js'); var utils = require('./utils.js'); function Process(d, file) { - logger.Log("[PCES]: File: " + file); + logger.Log("[PCES]:\tFile: " + file); try { @@ -44,26 +44,24 @@ function Process(d, file) { var oldRes = CheckData(oldFile); if (newRes.count > 0) - logger.Log("[NLOD]: new file result: " + newRes.count, logger.GetColor("blue")); + logger.Log("[NLOD]:\tnew file result: " + newRes.count, logger.GetColor("blue")); else - logger.Log("[NLOD]: new file NLOD error, " + newRes.log, logger.GetColor("redbg"), true); + logger.Log("[NLOD]:\tnew file NLOD error, " + newRes.log, logger.GetColor("redbg"), true); if (oldRes.count > 0) - logger.Log("[NLOD]: old public result: " + oldRes.count, logger.GetColor("blue")); + logger.Log("[NLOD]:\told public result: " + oldRes.count, logger.GetColor("blue")); else - logger.Log("[NLOD]: old public NLOD error, " + oldRes.log, logger.GetColor("redbg"), true); + logger.Log("[NLOD]:\told public NLOD error, " + oldRes.log, logger.GetColor("redbg"), true); utils.WriteFile(newFile, file); - logger.Log("[NLOD]: New data written to: " + file); + logger.Log("[NLOD]:\tNew data written to: " + file); return newRes.count - oldRes.count; - } else - logger.Log("[PCES]: No new data."); - + } } catch (e) { Beep(); - logger.Log("[ERR ]: Error at processing data! File: " + file, logger.GetColor("redbg")); + logger.Log("[ERR ]:\tError at processing data! File: " + file, logger.GetColor("redbg")); logger.Log(e.toString(), logger.GetColor("redbg")); } return -1; @@ -71,14 +69,16 @@ function Process(d, file) { function ProcessIncomingRequest(data) { + logger.Log("[PCES] ----------------------------------------------------------<", + logger.GetColor("yellow")); if (data == undefined) { - logger.Log("[PCES]: Recieved data is undefined!", logger.GetColor("redbg")); + logger.Log("[PCES]:\tRecieved data is undefined!", logger.GetColor("redbg")); return; } var d = SetupData(data); - logger.Log("[PCES]: Processing data: " + d.subj + " (" + d.type + ")"); + logger.Log("[PCES]:\tProcessing data: " + d.subj + " (" + d.type + ")"); if (d.subj == undefined){ logger.Log(JSON.stringify(d), logger.GetColor("red")); return; @@ -101,7 +101,7 @@ function ProcessIncomingRequest(data) { for (var i = 0; i < splitted.length; i++) if (splitted[i][0] == '?') count ++; - logger.Log("[PCES]: Test all question count: " + count, logger.GetColor("blue")); + logger.Log("[PCES]:\tTest all question count: " + count, logger.GetColor("blue")); } catch (e) {console.log("Error :c"); console.log(e);} var newPubItems = Process(d, publicFile); var newStatItems = Process(d, staticFile); @@ -109,6 +109,8 @@ function ProcessIncomingRequest(data) { utils.AppendToFile(logger.GetDateString() + "\n" + d.data, recievedFile); PrintNewCount(d, newPubItems, publicFile); PrintNewCount(d, newStatItems, staticFile); + logger.Log("[PCES] ----------------------------------------------------------<", + logger.GetColor("yellow")); } function PrintNewCount(d, newItems, file) { @@ -118,7 +120,7 @@ function PrintNewCount(d, newItems, file) { for (var i = 0; i < splitted.length; i++) if (splitted[i].startsWith("?")) count++; - logger.Log("[NEW ]: " + file + " All / New: " + count + " / " + newItems, logger.GetColor("cyan")); + logger.Log("[NEW ]:\t" + file + " All / New: " + count + " / " + newItems, logger.GetColor("cyan")); } } diff --git a/server.js b/server.js index 1987b66..c5c8eed 100755 --- a/server.js +++ b/server.js @@ -243,7 +243,7 @@ app.post('*', function(req, res) { stat.Load(); app.listen(port); -logger.Log("[START]: Server listening on port " + port + "...", logger.GetColor("yellow")); +logger.Log("[STRT]: Server listening on port " + port + "...", logger.GetColor("yellow")); function Log(req, toFile) { try {