From 14367c1746212474da277623ba7201f5fa14325c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 7 Mar 2018 19:40:22 +0100 Subject: [PATCH] FULL_LOG refactoring --- .vs/AACloudPlatform/v15/.suo | Bin 74240 -> 74240 bytes Assistant.js | 2 +- Azure File Storage.js | 8 ++++---- Context.js | 29 +++++++++++++++-------------- Datasource.js | 2 +- ExchangeAPI.js | 2 +- Interval Executor.js | 8 ++++---- Run.js | 8 ++++---- TradingBot.js | 13 ++++++------- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo index 546a023974a7cd1e2a70ccf72c6c401dafadd7f3..01866f77d78f51341f0d89c60431d51cc4c736c3 100644 GIT binary patch delta 2186 zcmcgteNa?Y6o2RP9xSrxTUdnzaW_d9P=_YTB0m<{#u?L@R@D4M9nrKhR0MYYDBua= zA~*tjVsJ(cd&@MGCa||rn{nz@{^36gsaU2{I9X%L_%X3FIfZl{yfw(CkC~>s^V@Uo zx#!$>@9(^Kj&fR5PK))Kb|x4@7KG8HMi3qh3=HU2UEkT^PGZvG)*rU#;ucm397AjX zig+j@1HglJDGy#nkCXu$@Es{h)I(8|tdfsnx8h}KB0RwRkOv~VBWxz$<`cQcFTgbP zu=4O$7>b%wokQ_`E){xNtO^i1g~KmOlpta_AlIdkKJmD*+v`m4!vP~Aj{4Iwp7M#(|f@0=#$pb zVk_Qv`~ur}C@qFzQCS?1n{gY|XT)H3vIugAyA2u&XZVwIqX)T*qKGgx#tr!TW%Pa1J?j#L5@%#Bv zOkEWjT;Iq7jq63;SWplZ058LeCF6KP$t}RXJq}#0n6bU|5;vFjvEYvE7=F<=6>!z= z{jtmG5jKJ@pGJ3e8(CXm0cr1HS#=zCRhlrnDg}dEtr*}wRWDLi5f}QZQQ7VNPv}wK7yq6iwVfFxX@DJ9(wp9vU>R3FbcvRa>0sf} zO-f=@a}<3?Be+mL`rP6SI|+7evF^v+H`@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$9j)RnMd~UjHpm?xh;^JZgyAl2z>|fmH&D1&bQN|bzuAX;^5#C-2FUlfqcyRRmUD2yzQ8e zeRsl6do^GI`ND-+yIK$q+WuMG_VWt&B_59--V)dcfwjJ}24=A9`hH?pJWIKF`%o*c z9%x0&^;jwPrxMT(-)o^f(L2U`Ce>PWHot~9Kh8N49>oc8%l z$@uei-aRCs^Wb!h=xTpd(L2E9JK5A44jZ%?55~X+Hh3CRY(-IV!Rib2sNpx5sM|&7 zZ5h1|`Goa!>NavaIahoVo7f^Qlky#ONS+HEmDv=-+SS)s?XBr8-|iZy8i`trqSNe( zH|et}0DHC;2VQg5mpx890(?pMV~n0^(vc=Em3LPHY6g{frbUHsv Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } /* Store local values. */ diff --git a/Azure File Storage.js b/Azure File Storage.js index d21834109..62e538245 100644 --- a/Azure File Storage.js +++ b/Azure File Storage.js @@ -37,7 +37,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) { function initialize(pDataOwnerBotCodeName, callBackFunction) { try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } if (pDataOwnerBotCodeName === undefined) { dataOwner = bot.codeName; @@ -72,7 +72,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) { function createFolder(pFolderPath, callBackFunction) { - if (LOG_INFO === true) { logger.write("[INFO] createFolder -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] createFolder -> Entering function."); } if (fileService === undefined) { @@ -165,7 +165,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) { callBackFunction(global.DEFAULT_FAIL_RESPONSE); } else { - if (LOG_INFO === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); } + if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); } callBackFunction(global.DEFAULT_OK_RESPONSE); } } @@ -234,7 +234,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) { callBackFunction(global.DEFAULT_FAIL_RESPONSE); } else { - if (LOG_INFO === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); } + if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); } callBackFunction(global.DEFAULT_OK_RESPONSE, text); } } diff --git a/Context.js b/Context.js index 057f67117..17cb9412f 100644 --- a/Context.js +++ b/Context.js @@ -73,7 +73,7 @@ try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } /* @@ -81,6 +81,7 @@ of the process. */ + initializeStorage(); function initializeStorage() { @@ -135,7 +136,7 @@ try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); } /* If the process run and was interrupted, there should be a status report that allows us to resume execution. */ @@ -152,7 +153,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getStatusReport -> onFileReceived -> Content received = " + text); } @@ -190,7 +191,7 @@ function getExecutionHistory(callBack) { try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); } let fileName = "Execution.History.json" let filePath = EXCHANGE_NAME + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process; @@ -205,7 +206,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> onFileReceived -> Content received = " + text); } @@ -238,7 +239,7 @@ function getExecutionContext(callBack) { try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); } let date = new Date(thisObject.statusReport.lastExecution); @@ -256,7 +257,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> onFileReceived -> Content received = " + text); } @@ -290,7 +291,7 @@ function createConext(callBack) { try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); } /* When the bot is executed for the very first time, there are a few files that do not exist and need to be created, and that @@ -364,7 +365,7 @@ function writeExecutionContext(callBack) { - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function."); } @@ -398,7 +399,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Content written = " + fileContent); } @@ -420,7 +421,7 @@ function writeExucutionHistory(callBack) { - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function."); } @@ -463,7 +464,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Content written = " + fileContent); } @@ -485,7 +486,7 @@ function writeStatusReport(callBack) { - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> Entering function."); } @@ -520,7 +521,7 @@ return; } - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> Content written = " + fileContent); } diff --git a/Datasource.js b/Datasource.js index ad07b8d8b..e5640df49 100644 --- a/Datasource.js +++ b/Datasource.js @@ -62,7 +62,7 @@ try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } initializeOliviaStorage(); diff --git a/ExchangeAPI.js b/ExchangeAPI.js index 89ee69159..0cf8b0ed0 100644 --- a/ExchangeAPI.js +++ b/ExchangeAPI.js @@ -31,7 +31,7 @@ try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } let apiKey = readApiKey(); poloniexApiClient = new POLONIEX_CLIENT_MODULE(apiKey.Key, apiKey.Secret); diff --git a/Interval Executor.js b/Interval Executor.js index 22c29800b..70b4a433e 100644 --- a/Interval Executor.js +++ b/Interval Executor.js @@ -4,7 +4,7 @@ const ROOT_DIR = './'; const MODULE_NAME = "Interval Executor"; - const LOG_INFO = true; + const FULL_LOG = true; let INTERVAL_MODULE; @@ -79,13 +79,13 @@ if (year !== undefined) { - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] Entering function 'start', with year = " + year + " and month = " + month); } } else { - if (LOG_INFO === true) { + if (FULL_LOG === true) { logger.write("[INFO] Entering function 'start'."); } @@ -109,7 +109,7 @@ try { - if (LOG_INFO === true) { + if (FULL_LOG === true) { if (processConfig.intervalMaxLoops !== 0) { diff --git a/Run.js b/Run.js index 5a23a5921..f237d2f75 100644 --- a/Run.js +++ b/Run.js @@ -1,5 +1,5 @@  -const LOG_INFO = true; +const FULL_LOG = true; /* The following global variable tells the system if it is running on test mode or production. */ @@ -192,7 +192,7 @@ for (let i = 0; i < botConfig.processes.length; i++) { function runTradingBot(pProcessConfig) { try { - if (LOG_INFO === true) { logger.write("[INFO] runTradingBot -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] runTradingBot -> Entering function."); } let tradingBot = TRADING_BOT_MODULE.newTradingBot(botConfig); tradingBot.initialize(vmConfig.bot.path, pProcessConfig, onInitializeReady); @@ -203,9 +203,9 @@ function runTradingBot(pProcessConfig) { tradingBot.start(whenStartFinishes); - function whenStartFinishes() { + function whenStartFinishes(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result === global.DEFAULT_OK_RESPONSE.result) { logger.write("[INFO] trading bot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)"); diff --git a/TradingBot.js b/TradingBot.js index bcbd12729..dee106d1b 100644 --- a/TradingBot.js +++ b/TradingBot.js @@ -4,7 +4,7 @@ const ROOT_DIR = './'; const MODULE_NAME = "Trading Bot"; - const LOG_INFO = true; + const FULL_LOG = true; let USER_BOT_MODULE; @@ -25,7 +25,7 @@ function initialize(pBotPath, pProcessConfig, callBackFunction) { try { - if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } processConfig = pProcessConfig; USER_BOT_MODULE = require(pBotPath + "/" + pProcessConfig.name + "/" + 'User.Bot'); @@ -41,20 +41,19 @@ function start(callBackFunction) { try { - if (LOG_INFO === true) { logger.write("[INFO] start -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> Entering function."); } loop(); function loop() { try { - if (LOG_INFO === true) { logger.write("[INFO] start -> loop -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> loop -> Entering function."); } /* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */ const UTILITIES = require(ROOT_DIR + 'Utilities'); const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage'); - const MARKETS_MODULE = require(ROOT_DIR + 'Markets'); const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); const POLONIEX_CLIENT_MODULE = require(ROOT_DIR + 'Poloniex API Client'); const EXCHANGE_API = require(ROOT_DIR + 'ExchangeAPI'); @@ -223,12 +222,12 @@ switch (nextWaitTime) { case 'Normal': { - if (LOG_INFO === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); } setTimeout(loop, processConfig.executionWaitTime); } break; case 'Retry': { - if (LOG_INFO === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); } setTimeout(loop, processConfig.retryWaitTime); } break;