From e65f320a36aa7a29cec897a5ba93485398469dcd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 9 Mar 2018 10:22:46 +0100 Subject: [PATCH] More Log fixing --- .vs/AACloudPlatform/v15/.suo | Bin 76800 -> 76800 bytes Assistant.js | 95 +++++++++++++++++++---------------- Context.js | 12 +++++ ExchangeAPI.js | 4 +- Utilities.js | 6 +++ 5 files changed, 72 insertions(+), 45 deletions(-) diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo index 07cda9ff69d3d71574687303704e13150505e83b..40fd77d6ec07167260a36d096d6b9a9e62c3d877 100644 GIT binary patch delta 728 zcmZ9JO=uHA6vy|ClkO%>iksFL+t5tY)QI&HLJ37mAi-0`6bqh&RX_k&7l->@aUx{FXHE$jcFSn`{Vuhy*Io6nVH_^)7yM~ zm;uKg7WJghZhW|pdA5aF{jJ4?*{*5YABretLFn@%M=y1f=q6O75x+^aQY}Gr5xvAO zs`XR$5k16dqK{CsVahQgC?D}RfWu69#-ejKXE5KgWwcS_41tRkf#;ZC-qSyF%mmKM zg8wpj-5&?``v!gsRAnWUg7V=E^MXk&cAzZ_!BODN3)*wW|6^F_{Nx3-A-!qwkx`J9 zwiMW5W=H7pS%X4~?ke+4&|FP^7dqG{4LingYBDH;$z8Bh+#X`~1!i?*>UNty*)a>{ z^jZ#$g(+NpnsoC6D+w!@Udm(c<$zq9yAAl>D#Nl{+Fc1?@u5?Gywnm>N7slU5^*B? zLXF82&*Qo|4vns+O^`k&ua&NY`SU>8q~p0IHQ`ewv%2!v_0pwi2Z|Aw(k7+72G9R62HOor}K@|2xo(7UYzQ>?&IPt;|%I?%!SUq z3yhx$Gd)Z{^NVLu&KH?DK490t2BB`~EAk{P@OvT+lu?US0L+uE>4=Eyu)ofWFI4uc8_ zt7BX`->aWPvtt`mqwiI?S%szQ)2!Ya)eH@A_Fj;Jmwtd9Gb9;(2cWJ9by=u{u&)(w zkh1OrtmD|)Z2kfGF}dA~XL2?auq`)(lP`zpV{R1iPF};}!m|Br&5I)&I=!y0_yS9O z|8GP;taG7L=I33&@~f+M;hhK^!oTs6Q`4u-p}4hB_bogAF8m`XaE2J diff --git a/Assistant.js b/Assistant.js index 03275c99d..2b247af77 100644 --- a/Assistant.js +++ b/Assistant.js @@ -281,9 +281,61 @@ getPositionTradesAtExchange(botContext.executionContext.positions[i].id, confirmOrderWasExecuted); + function getPositionTradesAtExchange(pPositionId, innerCallBack) { + + try { + + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> pPositionId = " + pPositionId); } + + /* + + Given one position, we request all the associated trades to it. + + */ + + exchangeAPI.getExecutedTrades(pPositionId, onResponse); + + function onResponse(err, pTrades) { + + try { + switch (err.result) { + case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested. + logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Execution finished well. :-)"); + innerCallBack(pTrades); + } + break; + case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Retry Later. Requesting Execution Retry."); + callBack(global.DEFAULT_RETRY_RESPONSE); + return; + } + break; + case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Operation Failed. Aborting the process."); + callBack(global.DEFAULT_FAIL_RESPONSE); + return; + } + break; + } + } catch (err) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> err = " + err.message); + callBack(global.DEFAULT_FAIL_RESPONSE); + } + } + } catch (err) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> err = " + err.message); + callBack(global.DEFAULT_FAIL_RESPONSE); + } + } + function confirmOrderWasExecuted(pTrades) { try { + + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> pTrades = " + JSON.stringify(pTrades)); } + /* To confirm everything is ok, we will add all the amounts on trades asociated to the order and @@ -349,49 +401,6 @@ } } - function getPositionTradesAtExchange(pPositionId, innerCallBack) { - - try { - /* - - Given one position, we request all the associated trades to it. - - */ - - exchangeAPI.getExecutedTrades(pPositionId, onResponse); - - function onResponse(err, pTrades) { - - try { - switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested. - innerCallBack(pTrades); - } - break; - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Retry Later. Requesting Execution Retry."); - callBack(global.DEFAULT_RETRY_RESPONSE); - return; - } - break; - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Operation Failed. Aborting the process."); - callBack(global.DEFAULT_FAIL_RESPONSE); - return; - } - break; - } - } catch (err) { - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> err = " + err.message); - callBack(global.DEFAULT_FAIL_RESPONSE); - } - } - } catch (err) { - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> err = " + err.message); - callBack(global.DEFAULT_FAIL_RESPONSE); - } - } - } catch (err) { logger.write("[ERROR] ordersExecutionCheck -> loopBody -> err = " + err.message); callBack(global.DEFAULT_FAIL_RESPONSE); diff --git a/Context.js b/Context.js index 258c63e12..cbad33bed 100644 --- a/Context.js +++ b/Context.js @@ -397,6 +397,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> err = " + err.message); callBack(err); @@ -409,6 +411,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); @@ -453,6 +457,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> err = " + err.message); callBack(err); @@ -475,6 +481,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); @@ -519,6 +527,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeStatusReport -> onFolderCreated -> err = " + err.message); callBack(err); @@ -533,6 +543,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); diff --git a/ExchangeAPI.js b/ExchangeAPI.js index 2a5f3a3c3..e4e589732 100644 --- a/ExchangeAPI.js +++ b/ExchangeAPI.js @@ -361,8 +361,8 @@ try { if (FULL_LOG === true) { logger.write("[INFO] movePosition -> Entering function."); } - if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pPosition = " + JSON.stringify(pPosition)); } - if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pNewRate = " + pNewRate); } + if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); } + if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pNewRate = " + pNewRate); } poloniexApiClient.moveOrder(pPosition.id, pNewRate, pPosition.amountB, onExchangeCallReturned); diff --git a/Utilities.js b/Utilities.js index 1f98a896b..b2a0384c4 100644 --- a/Utilities.js +++ b/Utilities.js @@ -27,6 +27,8 @@ exports.newUtilities = function newUtilities(BOT) { function createFolderIfNeeded(path, azureFileStorage, callBackFunction) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> Entering function."); } + let splittedPath = path.split("/"); let partialPath = ''; @@ -37,6 +39,8 @@ exports.newUtilities = function newUtilities(BOT) { function loop() { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> Entering function."); } + partialPath = partialPath + separator + splittedPath[i]; separator = "/"; @@ -46,6 +50,8 @@ exports.newUtilities = function newUtilities(BOT) { function checkLoop(err) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> checkLoop -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.message); callBackFunction(err);