From 1d161dddc07f26a0083b3f5e68cf45c82f6f6d46 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 5 Dec 2019 10:39:51 +0100 Subject: [PATCH] Bug Fixed and Not deleting logs with errors --- DebugLog.js | 15 +++++++++++++-- MultiPeriod.js | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DebugLog.js b/DebugLog.js index a51b02b0b..6374eb201 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -90,8 +90,19 @@ exports.newDebugLog = function newDebugLog() { thisObject.bot.LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName) if (thisObject.bot.LOGS_TO_DELETE_QUEUE.length > thisObject.bot.DELETE_QUEUE_SIZE) { let fileToDelete = thisObject.bot.LOGS_TO_DELETE_QUEUE[0] - thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0,1) - fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete); + thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0, 1) + /* Will delete this file only if it does not contains ERROR inside. */ + let fileContent = fileStorage.getTextFile(thisObject.bot.devTeam, fileToDelete, onGetFile, true) + function onGetFile(err, fileContent) { + if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (fileContent.indexOf("ERROR") < 0) { + /* Logs will only be deleted when they contain no ERROR in them. */ + fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete); + } + } else { + fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete); + } + } } function writeLog() { diff --git a/MultiPeriod.js b/MultiPeriod.js index 00961e350..37ca1fff8 100644 --- a/MultiPeriod.js +++ b/MultiPeriod.js @@ -333,7 +333,7 @@ if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriodsMarketFiles -> periodsLoopBody -> dependencyLoopBody -> getFile -> onFileReceived -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriodsMarketFiles -> periodsLoopBody -> dependencyLoopBody -> getFile -> onFileReceived -> err = " + err.message); callBackFunction(err); return; } @@ -987,7 +987,7 @@ let dataRange = { begin: pBegin.valueOf(), - end: pEnd.valueOf() + end: pEnd.valueOf() + ONE_DAY_IN_MILISECONDS }; let fileContent = JSON.stringify(dataRange);