More Log fixing

This commit is contained in:
Luis Fernando Molina committed 2018-03-09 10:22:46 +01:00
1 parent 8a0020ab84
commit e65f320a36
5 files changed
+72 -45

No files matched your search

Binary file not shown.
+52 -43
View File
@@ -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);
+12
View File
@@ -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);
+2 -2
View File
@@ -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);
+6
View File
@@ -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);