Logs and Error Handling improvements

This commit is contained in:
Luis Fernando Molina committed 2018-05-30 09:29:14 +02:00
1 parent 38fe8dfa2b
commit 0ef1dcd891
5 files changed
+61 -32

No files matched your search

+3 -3
View File
@@ -1,6 +1,6 @@
function newCloudRequire(BOT, DEBUG_MODULE) {
const FULL_LOG = true;
const INFO_LOG = true;
const LOG_FILE_CONTENT = false;
const MODULE_NAME = "Cloud Require";
@@ -23,7 +23,7 @@
try {
if (FULL_LOG === true) { logger.write("[INFO] downloadBot -> Entering function."); }
if (INFO_LOG === true) { logger.write("[INFO] downloadBot -> Entering function."); }
let filePath = "Bots" + "/" + bot.devTeam + "/" + bot.repo + "/" + pProcessConfig.name + "/" + "User.Bot.js";
@@ -46,7 +46,7 @@
try {
if (FULL_LOG === true) { logger.write("[INFO] downloadCommons -> Entering function."); }
if (INFO_LOG === true) { logger.write("[INFO] downloadCommons -> Entering function."); }
let filePath = "Bots" + "/" + bot.devTeam + "/" + bot.repo + "/" + "Commons.js";
+53 -24
View File
@@ -20,60 +20,89 @@ function newCloudVM() {
function onBotPlayPressed(pUI_COMMANDS) {
window.SHALL_BOT_STOP = false;
try {
window.CURRENT_ENVIRONMENT = "Develop";
window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions();
window.EXCHANGE_KEYS = ecosystem.getExchangeKeys();
window.USER_LOGGED_IN = window.localStorage.getItem("userName");
window.USER_DEV_TEAM = window.localStorage.getItem("devTeam");
if (INFO_LOG === true) { logger.write("[INFO] onBotPlayPressed -> Entering function."); }
root.initialize(pUI_COMMANDS, onInitialized);
window.SHALL_BOT_STOP = false;
function onInitialized() {
window.CURRENT_ENVIRONMENT = "Develop";
window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions();
window.EXCHANGE_KEYS = ecosystem.getExchangeKeys();
window.USER_LOGGED_IN = window.localStorage.getItem("userName");
window.USER_DEV_TEAM = window.localStorage.getItem("devTeam");
root.start();
root.initialize(pUI_COMMANDS, onInitialized);
intervalHandler = setInterval(checkForChangesInBotCode, 10000);
function onInitialized() {
try {
if (INFO_LOG === true) { logger.write("[INFO] onBotPlayPressed -> Entering function."); }
root.start();
intervalHandler = setInterval(checkForChangesInBotCode, 10000);
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onBotPlayPressed -> onInitialized -> err.message = " + err.message); }
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onBotPlayPressed -> err.message = " + err.message); }
}
}
function onBotStopPressed() {
if (INFO_LOG === true) { logger.write("[INFO] onBotStopPressed -> Entering function."); }
window.SHALL_BOT_STOP = true;
}
function checkForChangesInBotCode() {
let botFunction = newUserBot;
try {
if (botFunction !== undefined) {
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> Entering function."); }
let currentBotCode = botFunction.toString();
let botFunction = newUserBot;
if (previousBotCode !== "") {
if (botFunction !== undefined) {
if (currentBotCode !== previousBotCode) {
let currentBotCode = botFunction.toString();
console.log("Bot code changes detected.");
if (previousBotCode !== "") {
let path = "AABrowserAPI" + "/"
+ "saveBotCode"
;
if (currentBotCode !== previousBotCode) {
callServer(currentBotCode, path, onServerResponse);
console.log("Bot code changes detected.");
function onServerResponse(err) {
let path = "AABrowserAPI" + "/"
+ "saveBotCode"
;
console.log("Server responded: " + err);
callServer(currentBotCode, path, onServerResponse);
function onServerResponse(err) {
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> Entering function."); }
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> err = " + err); }
}
}
}
previousBotCode = currentBotCode;
}
previousBotCode = currentBotCode;
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] checkForChangesInBotCode -> err.message = " + err.message); }
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
function newPoloniexAPIClient(pKey, pSecret) {
const FULL_LOG = true;
const INFO_LOG = true;
const LOG_FILE_CONTENT = false;
let key = pKey;
@@ -29,7 +29,7 @@
let stringExchangeResponse = JSON.stringify(exchangeResponse);
let stringExchangeErr = JSON.stringify(exchangeErr);
if (FULL_LOG === true) { logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (INFO_LOG === true) { logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (LOG_FILE_CONTENT === true) { logger.write("[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
if (stringExchangeErr.indexOf("ETIMEDOUT") > 0 ||
+2 -2
View File
@@ -401,7 +401,7 @@
analizeResponse: function (logger, exchangeErr, exchangeResponse, notOkCallBack, okCallBack) {
const FULL_LOG = false;
const INFO_LOG = false;
const LOG_FILE_CONTENT = false;
/* This function analizes the different situations we might encounter trying to access Poloniex and returns appropiate standard errors. */
@@ -411,7 +411,7 @@
let stringExchangeResponse = JSON.stringify(exchangeResponse);
let stringExchangeErr = JSON.stringify(exchangeErr);
if (FULL_LOG === true) { logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (INFO_LOG === true) { logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
if (LOG_FILE_CONTENT === true) { logger.write("[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
if (stringExchangeErr.indexOf("ETIMEDOUT") > 0 ||
+1 -1
View File
@@ -1,6 +1,6 @@
function newAppLoader() {
const FULL_LOG = false;
const INFO_LOG = false;
const LOG_FILE_CONTENT = false;
const MODULE_NAME = "App Loader";