Looging look improvements

This commit is contained in:
YourFriendlyNeighborhoodDealer 2018-11-22 14:37:11 +01:00
parent e55c7beb37
commit 95a6ab88d0
2 changed files with 17 additions and 15 deletions

View file

@ -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"));
}
}