diff --git a/DebugLog.js b/DebugLog.js index a97031bfe..c7f48f449 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -15,7 +15,7 @@ let thisObject = { bot: undefined, write: write, - flush: flush, + newInternalLoop: newInternalLoop, persist: persist, // This method is executed at the end of each Main Loop. initialize: initialize }; @@ -24,7 +24,7 @@ let disableLogging; - let flushCounter = 0; + let internalLoopCounter = -1; return thisObject; @@ -39,15 +39,17 @@ } } - function flush() { + function newInternalLoop(pBot, pProcess) { - /* - This method will partition the loop log file into several chuncks, each time is executed. It is intended for long processes that needs to show their advance - and release memory used by accumulating messages in this module. - */ - flushCounter++; + console.log(new Date().toISOString() + " " + strPad(pBot, 20) + " " + strPad(pProcess, 30) + " Entered into Internal Loop # " + strPad(internalLoopCounter + 1, 4)); + persist(); + + function strPad(str, max) { + str = str.toString(); + return str.length < max ? strPad(" " + str, max) : str; + } } function persist() { @@ -56,6 +58,8 @@ try { + internalLoopCounter++; + if (global.CURRENT_EXECUTION_AT === "Browser") { //console.log("[INFO] DebugLog -> persist -> We do not persist logs while running at the Browser"); @@ -86,9 +90,9 @@ let fileName; - if (flushCounter > 0) { + if (internalLoopCounter >= 0) { - fileName = "Loop." + pad(thisObject.bot.loopCounter, 8) + "." + pad(flushCounter, 4) + ".json"; + fileName = "Loop." + pad(thisObject.bot.loopCounter, 8) + "." + pad(internalLoopCounter, 4) + ".json"; } else { diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index 73d5a4eb7..cea2c0f5f 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -150,7 +150,7 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Loop # " + pad(Number(bot.loopCounter) + 1, 5)); + console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8)); /* For each loop we want to create a new log file. */ diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index e2468d049..97695b032 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -151,7 +151,7 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Loop # " + pad(Number(bot.loopCounter) + 1, 5 )); + console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8 )); /* For each loop we want to create a new log file. */ @@ -255,7 +255,7 @@ try { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); } - + usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, BLOB_STORAGE); usertBot.initialize(statusDependencies, pMonth, pYear, onInizialized); diff --git a/Project.njsproj b/Project.njsproj index 34e1c0483..be97bff0b 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -66,6 +66,7 @@ Code + diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index af52b8ce2..9a06d4f0e 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -151,7 +151,7 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Loop # " + pad(Number(bot.loopCounter) + 1, 5)); + console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8)); /* For each loop we want to create a new log file. */