From c6917408822037ded7080024696c3d94786f187f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Nov 2020 13:14:24 +0100 Subject: [PATCH] Cleaning Conditional Logs part 2 --- TaskServer/CloudUtilities.js | 22 ++++------------------ TaskServer/Commons.js | 13 ------------- TaskServer/DataSet.js | 23 +++++------------------ TaskServer/LearningSession.js | 1 - 4 files changed, 9 insertions(+), 50 deletions(-) diff --git a/TaskServer/CloudUtilities.js b/TaskServer/CloudUtilities.js index 1c8a9ccb6..42f639f92 100644 --- a/TaskServer/CloudUtilities.js +++ b/TaskServer/CloudUtilities.js @@ -1,8 +1,6 @@  exports.newCloudUtilities = function newCloudUtilities(logger) { - const FULL_LOG = true; - const MODULE_NAME = "Cloud Utilities"; let utilities = { @@ -16,9 +14,7 @@ exports.newCloudUtilities = function newCloudUtilities(logger) { function createFolderIfNeeded(path, azureFileStorage, callBackFunction) { try { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> Entering function."); } - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> path = " + path); } + logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> path = " + path) let splittedPath = path.split("/"); @@ -29,36 +25,26 @@ exports.newCloudUtilities = function newCloudUtilities(logger) { loop(); function loop() { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> path = " + path); } + logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> path = " + path) partialPath = partialPath + separator + splittedPath[i]; separator = "/"; - i++; - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> partialPath = " + partialPath); } + logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> partialPath = " + partialPath) azureFileStorage.createFolder(partialPath, checkLoop); function checkLoop(err) { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] createFolderIfNeeded -> loop -> checkLoop -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - logger.write(MODULE_NAME, "[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = "+ err.stack); + logger.write(MODULE_NAME, "[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.stack); callBackFunction(err); return; } if (i === splittedPath.length) { - callBackFunction(global.DEFAULT_OK_RESPONSE); - } else { - loop(); - } } } diff --git a/TaskServer/Commons.js b/TaskServer/Commons.js index b8cccb1d2..c5929c4ae 100644 --- a/TaskServer/Commons.js +++ b/TaskServer/Commons.js @@ -1,8 +1,5 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES, FILE_STORAGE) { - const FULL_LOG = true; - const LOG_FILE_CONTENT = false; - const MODULE_NAME = "Commons"; let thisObject = { @@ -454,9 +451,6 @@ function generateFileContent(records, recordDefinition, resultsWithIrregularPeriods, processingDailyFiles, currentDay, callBackFunction) { try { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> generateFileContent -> Entering function."); } - let fileContent = ""; let recordSeparator = ""; @@ -519,9 +513,6 @@ function writeFile(contextSummary, fileContent, anotherFileWritten, processingDailyFiles, timeFrameLabel, currentDay, callBackFunction) { try { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFile -> Entering function."); } - let market = bot.market; let fileName = 'Data.json'; let dateForPath = '' @@ -539,10 +530,6 @@ function onFileCreated(err) { try { - - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFile -> onFileCreated -> Entering function."); } - if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFile -> onFileCreated -> fileContent = " + fileContent); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFile -> onFileCreated -> err = " + err.stack); diff --git a/TaskServer/DataSet.js b/TaskServer/DataSet.js index c019dea05..4c6c99163 100644 --- a/TaskServer/DataSet.js +++ b/TaskServer/DataSet.js @@ -25,7 +25,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { try { thisObject.node = dataDependency.referenceParent; logger.fileName = MODULE_NAME - + /* Some very basic validations that we have all the information needed. */ if (thisObject.node === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Data Dependency without Reference Parent -> dataDependency = " + JSON.stringify(dataDependency)); @@ -87,13 +87,13 @@ exports.newDataSet = function newDataSet(BOT, logger) { if (networkNode === undefined) { logger.write(MODULE_NAME, "[WARN] initialize -> Network Node not found.") logger.write(MODULE_NAME, "[WARN] initialize -> Initialization Failed because we could not find where the data of this dataset is located within the network. Check the logs for more info."); - logger.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + datasetProductDefinition.name + " for " + bot.exchange + " " + bot.market.baseAsset + "/" + bot.market.quotedAsset + " is stored within the network."); + logger.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + datasetProductDefinition.name + " for " + bot.exchange + " " + bot.market.baseAsset + "/" + bot.market.quotedAsset + " is stored within the network."); callBackFunction(global.DEFAULT_OK_RESPONSE, false); return } /* We found where the data is located on the network. */ - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving data from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.'); } + logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving data from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.') fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort); callBackFunction(global.DEFAULT_OK_RESPONSE, true); @@ -114,9 +114,6 @@ exports.newDataSet = function newDataSet(BOT, logger) { function getTextFile(pFolderPath, pFileName, callBackFunction) { try { - - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] getTextFile -> Entering function."); } - let mine = thisObject.node.parentNode.parentNode.parentNode.config.codeName let mineType = thisObject.node.parentNode.parentNode.parentNode.type.replace(' ', '-') let project = thisObject.node.parentNode.parentNode.parentNode.project @@ -129,11 +126,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { - - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] getTextFile -> onFileReceived -> Entering function."); } - callBackFunction(err, text); - } } catch (err) { @@ -146,9 +139,8 @@ exports.newDataSet = function newDataSet(BOT, logger) { try { - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createTextFile -> Entering function."); } - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createTextFile -> pFolderPath = " + pFolderPath); } - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createTextFile -> pFileName = " + pFileName); } + logger.write(MODULE_NAME, "[INFO] createTextFile -> pFolderPath = " + pFolderPath) + logger.write(MODULE_NAME, "[INFO] createTextFile -> pFileName = " + pFileName) let ownerId = thisObject.node.dataMine + "-" + thisObject.node.bot let botId = bot.dataMine + "-" + bot.codeName @@ -170,11 +162,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { fileStorage.createTextFile(filePath, pFileContent, onFileCreated); function onFileCreated(err) { - - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createTextFile -> onFileCreated -> Entering function."); } - callBackFunction(err); - } } catch (err) { @@ -182,5 +170,4 @@ exports.newDataSet = function newDataSet(BOT, logger) { callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } - }; diff --git a/TaskServer/LearningSession.js b/TaskServer/LearningSession.js index 2a40cdb72..a76471d77 100644 --- a/TaskServer/LearningSession.js +++ b/TaskServer/LearningSession.js @@ -1,7 +1,6 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) { const MODULE_NAME = "Learning Session" - const FULL_LOG = true; let thisObject = { initialize: initialize