mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Looging look improvements
This commit is contained in:
parent
e55c7beb37
commit
95a6ab88d0
2 changed files with 17 additions and 15 deletions
30
actions.js
30
actions.js
|
@ -32,7 +32,7 @@ var logger = require('./logger.js');
|
||||||
var utils = require('./utils.js');
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
function Process(d, file) {
|
function Process(d, file) {
|
||||||
logger.Log("[PCES]: File: " + file);
|
logger.Log("[PCES]:\tFile: " + file);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -44,26 +44,24 @@ function Process(d, file) {
|
||||||
var oldRes = CheckData(oldFile);
|
var oldRes = CheckData(oldFile);
|
||||||
|
|
||||||
if (newRes.count > 0)
|
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
|
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)
|
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
|
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);
|
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;
|
return newRes.count - oldRes.count;
|
||||||
} else
|
}
|
||||||
logger.Log("[PCES]: No new data.");
|
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Beep();
|
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"));
|
logger.Log(e.toString(), logger.GetColor("redbg"));
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -71,14 +69,16 @@ function Process(d, file) {
|
||||||
|
|
||||||
function ProcessIncomingRequest(data) {
|
function ProcessIncomingRequest(data) {
|
||||||
|
|
||||||
|
logger.Log("[PCES] ----------------------------------------------------------<",
|
||||||
|
logger.GetColor("yellow"));
|
||||||
if (data == undefined) {
|
if (data == undefined) {
|
||||||
logger.Log("[PCES]: Recieved data is undefined!", logger.GetColor("redbg"));
|
logger.Log("[PCES]:\tRecieved data is undefined!", logger.GetColor("redbg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = SetupData(data);
|
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){
|
if (d.subj == undefined){
|
||||||
logger.Log(JSON.stringify(d), logger.GetColor("red"));
|
logger.Log(JSON.stringify(d), logger.GetColor("red"));
|
||||||
return;
|
return;
|
||||||
|
@ -101,7 +101,7 @@ function ProcessIncomingRequest(data) {
|
||||||
for (var i = 0; i < splitted.length; i++)
|
for (var i = 0; i < splitted.length; i++)
|
||||||
if (splitted[i][0] == '?')
|
if (splitted[i][0] == '?')
|
||||||
count ++;
|
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);}
|
} catch (e) {console.log("Error :c"); console.log(e);}
|
||||||
var newPubItems = Process(d, publicFile);
|
var newPubItems = Process(d, publicFile);
|
||||||
var newStatItems = Process(d, staticFile);
|
var newStatItems = Process(d, staticFile);
|
||||||
|
@ -109,6 +109,8 @@ function ProcessIncomingRequest(data) {
|
||||||
utils.AppendToFile(logger.GetDateString() + "\n" + d.data, recievedFile);
|
utils.AppendToFile(logger.GetDateString() + "\n" + d.data, recievedFile);
|
||||||
PrintNewCount(d, newPubItems, publicFile);
|
PrintNewCount(d, newPubItems, publicFile);
|
||||||
PrintNewCount(d, newStatItems, staticFile);
|
PrintNewCount(d, newStatItems, staticFile);
|
||||||
|
logger.Log("[PCES] ----------------------------------------------------------<",
|
||||||
|
logger.GetColor("yellow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function PrintNewCount(d, newItems, file) {
|
function PrintNewCount(d, newItems, file) {
|
||||||
|
@ -118,7 +120,7 @@ function PrintNewCount(d, newItems, file) {
|
||||||
for (var i = 0; i < splitted.length; i++)
|
for (var i = 0; i < splitted.length; i++)
|
||||||
if (splitted[i].startsWith("?"))
|
if (splitted[i].startsWith("?"))
|
||||||
count++;
|
count++;
|
||||||
logger.Log("[NEW ]: " + file + " All / New: " + count + " / " + newItems, logger.GetColor("cyan"));
|
logger.Log("[NEW ]:\t" + file + " All / New: " + count + " / " + newItems, logger.GetColor("cyan"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ app.post('*', function(req, res) {
|
||||||
|
|
||||||
stat.Load();
|
stat.Load();
|
||||||
app.listen(port);
|
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) {
|
function Log(req, toFile) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue