Error Logging IMproved Again

This commit is contained in:
Luis Fernando Molina committed 2018-09-19 14:26:01 +02:00
1 parent 2829ab7c06
commit 27502ed54d
2 files changed
+42 -42

No files matched your search

+27 -27
View File
@@ -29,7 +29,7 @@
function initialize(callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> initialize -> Entering function."); }
let exchange = global.EXCHANGE_NAME.toLowerCase() + 'Client.js';
let api = require('./Wrappers/' + exchange);
@@ -38,7 +38,7 @@
callBackFunction(global.DEFAULT_OK_RESPONSE);
} catch (err) {
console.log("[ERROR] initialize -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> initialize -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -82,12 +82,12 @@
function getExchangeProperties() {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getExchangeProperties -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getExchangeProperties -> Entering function."); }
return apiClient.getExchangeProperties();
} catch (err) {
console.log("[ERROR] getExchangeProperties -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> getExchangeProperties -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -104,12 +104,12 @@
function getTicker(pMarket, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getTicker -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getTicker -> Entering function."); }
apiClient.getTicker(pMarket, callBack);
} catch (err) {
console.log("[ERROR] getTicker -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> getTicker -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -122,13 +122,13 @@
function getOpenPositions(pMarket, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getOpenPositions -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] getOpenPositions -> pMarket = " + JSON.stringify(pMarket)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getOpenPositions -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getOpenPositions -> pMarket = " + JSON.stringify(pMarket)); }
apiClient.getOpenPositions(pMarket, callBack);
} catch (err) {
console.log("[ERROR] getOpenPositions -> Error = " + err.message);
console.log("[ERROR] ExchangeAPI -> getOpenPositions -> Error = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -140,13 +140,13 @@
function getExecutedTrades(pPositionId, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getExecutedTrades -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] getExecutedTrades -> pPositionId = " + pPositionId); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getExecutedTrades -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getExecutedTrades -> pPositionId = " + pPositionId); }
apiClient.getExecutedTrades(pPositionId, callBack);
} catch (err) {
console.log("[ERROR] getExecutedTrades -> Error = " + err.message);
console.log("[ERROR] ExchangeAPI -> getExecutedTrades -> Error = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -158,12 +158,12 @@
function putPosition(pMarket, pType, pRate, pAmountA, pAmountB, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> pMarket = " + JSON.stringify(pMarket)); }
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> pType = " + pType); }
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> pRate = " + truncDecimals(pRate)); }
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> pAmountA = " + truncDecimals(pAmountA)); }
if (CONSOLE_LOG === true) { console.log("[INFO] putPosition -> pAmountB = " + truncDecimals(pAmountB)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> pMarket = " + JSON.stringify(pMarket)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> pType = " + pType); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> pRate = " + truncDecimals(pRate)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> pAmountA = " + truncDecimals(pAmountA)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> putPosition -> pAmountB = " + truncDecimals(pAmountB)); }
let check = isValidOrder({
market: getMarketConfig(),
@@ -183,16 +183,16 @@
return;
}
console.log("[ERROR] putPosition -> pType must be either 'buy' or 'sell'.");
console.log("[ERROR] ExchangeAPI -> putPosition -> pType must be either 'buy' or 'sell'.");
callBack(global.DEFAULT_FAIL_RESPONSE);
} else {
console.log("[ERROR] putPosition -> The order is invalid: " + check.reason);
console.log("[ERROR] ExchangeAPI -> putPosition -> The order is invalid: " + check.reason);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
} catch (err) {
console.log("[ERROR] putPosition -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> putPosition -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -204,14 +204,14 @@
function movePosition(pPosition, pNewRate, pNewAmountB, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] movePosition -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); }
if (CONSOLE_LOG === true) { console.log("[INFO] movePosition -> pNewRate = " + truncDecimals(pNewRate)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> movePosition -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> movePosition -> pPosition = " + JSON.stringify(pPosition)); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> movePosition -> pNewRate = " + truncDecimals(pNewRate)); }
apiClient.movePosition(pPosition, truncDecimals(pNewRate), truncDecimals(pNewAmountB), callBack);
} catch (err) {
console.log("[ERROR] movePosition -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> movePosition -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -233,12 +233,12 @@
function getPublicTradeHistory(assetA, assetB, startTime, endTime, callBack) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getTradeHistory -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> getTradeHistory -> Entering function."); }
apiClient.getPublicTradeHistory(assetA, assetB, startTime, endTime, callBack);
} catch (err) {
console.log("[ERROR] getTradeHistory -> err = " + err.message);
console.log("[ERROR] ExchangeAPI -> getTradeHistory -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
+15 -15
View File
@@ -123,7 +123,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getOpenPositions -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> getOpenPositions -> Entering function."); }
const handle = (err, response) => {
let exchangePositions = [];
@@ -148,7 +148,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] getOpenPositions -> err = " + err.message);
console.log("[ERROR] poloniexClient -> getOpenPositions -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -170,7 +170,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getExecutedTrades -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> getExecutedTrades -> Entering function."); }
const handle = (err, response) => {
let trades = [];
@@ -199,7 +199,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] getExecutedTrades -> err = " + err.message);
console.log("[ERROR] poloniexClient -> getExecutedTrades -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -212,7 +212,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] buy -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> buy -> Entering function."); }
const handle = (err, response) => {
let orderNumber;
@@ -227,7 +227,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] buy -> err = " + err.message);
console.log("[ERROR] poloniexClient -> buy -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -240,7 +240,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] sell -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> sell -> Entering function."); }
const handle = (err, response) => {
let orderNumber;
@@ -255,7 +255,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] sell -> err = " + err.message);
console.log("[ERROR] poloniexClient -> sell -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -268,7 +268,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] movePosition -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> movePosition -> Entering function."); }
const handle = (err, response) => {
let orderNumber;
@@ -283,7 +283,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] movePosition -> err = " + err.message);
console.log("[ERROR] poloniexClient -> movePosition -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -306,7 +306,7 @@
try {
if (CONSOLE_LOG === true) { console.log("[INFO] getPublicTradeHistory -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] poloniexClient -> getPublicTradeHistory -> Entering function."); }
const handle = (err, response) => {
let trades = [];
@@ -332,7 +332,7 @@
retry(null, fetch, handle);
} catch (err) {
console.log("[ERROR] getPublicTradeHistory -> err = " + err.message);
console.log("[ERROR] poloniexClient -> getPublicTradeHistory -> err = " + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -352,8 +352,8 @@
let stringExchangeResponse = JSON.stringify(exchangeResponse);
try {
if (FULL_LOG === true) { console.log("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (FULL_LOG === true) { console.log("[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
if (FULL_LOG === true) { console.log("[INFO] poloniexClient -> analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (FULL_LOG === true) { console.log("[INFO] poloniexClient -> analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
if (exchangeErr) {
error = global.DEFAULT_FAIL_RESPONSE;
@@ -397,7 +397,7 @@
return callBack(error, exchangeResponse);
} catch (err) {
console.log("[ERROR] analizeResponse -> err.message = " + err.message);
console.log("[ERROR] poloniexClient -> analizeResponse -> err.message = " + err.message);
return callBack(global.DEFAULT_FAIL_RESPONSE, exchangeResponse);
}
}