Cleaning Console Debug stuff

This commit is contained in:
Luis Fernando Molina committed 2018-05-24 12:46:33 +02:00
1 parent b56e0f0125
commit 0baac2f443
5 files changed
+540 -518

No files matched your search

+63 -61
View File
@@ -89,12 +89,14 @@ exports.newRoot = function newRoot() {
let cloudStorage;
let logDisplace = "AACloud" + " ";
return thisObject;
function initialize(callBackFunction) {
try {
console.log("[INFO] Root -> initialize -> Entering function. ");
console.log(logDisplace + "Root : [INFO] initialize -> Entering function. ");
const BLOB_STORAGE = require(ROOT_DIR + 'BlobStorage');
cloudStorage = BLOB_STORAGE.newBlobStorage();
@@ -113,7 +115,7 @@ exports.newRoot = function newRoot() {
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] Root -> initialize -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [INFO] initialize -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
@@ -121,19 +123,19 @@ exports.newRoot = function newRoot() {
global.PLATFORM_CONFIG = JSON.parse(text);
callBackFunction();
} catch (err) {
console.log("[ERROR] Root -> initialize -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
}
} else {
console.log("[ERROR] Root -> initialize -> onInizialized -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> onInizialized -> err = " + err.message);
return;
}
}
}
catch (err) {
console.log("[ERROR] Root -> initialize -> err.message = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> err.message = " + err.message);
return;
}
}
@@ -167,8 +169,8 @@ exports.newRoot = function newRoot() {
if (listItem.enabled !== "true") {
console.log("[INFO] Root -> start -> Skipping process for being disabled.");
console.log("[INFO] Root -> start -> listItem.process = " + listItem.process);
console.log(logDisplace + "Root : [INFO] start -> Skipping process for being disabled.");
console.log(logDisplace + "Root : [INFO] start -> listItem.process = " + listItem.process);
continue;
}
@@ -182,7 +184,7 @@ exports.newRoot = function newRoot() {
function getBotConfig() {
try {
console.log("[INFO] Root -> start -> getBotConfig -> Entering function. ");
console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Entering function. ");
const BLOB_STORAGE = require(ROOT_DIR + 'BlobStorage');
let cloudStorage = BLOB_STORAGE.newBlobStorage(listItem);
@@ -201,7 +203,7 @@ exports.newRoot = function newRoot() {
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
@@ -210,19 +212,19 @@ exports.newRoot = function newRoot() {
botConfig.repo = listItem.repo;
findProcess();
} catch (err) {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
}
} else {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> err = " + err.message);
return;
}
}
}
catch (err) {
console.log("[ERROR] Root -> start -> getBotConfig -> err.message = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> err.message = " + err.message);
return;
}
}
@@ -230,7 +232,7 @@ exports.newRoot = function newRoot() {
function findProcess() {
try {
if (FULL_LOG === true) { console.log("[INFO] Root -> start -> findProcess -> Entering function. "); }
if (FULL_LOG === true) { console.log(logDisplace + "Root : [INFO] start -> findProcess -> Entering function. "); }
botConfig.process = listItem.process;
botConfig.debug = {};
@@ -243,14 +245,14 @@ exports.newRoot = function newRoot() {
botConfig.loopCounter = 0;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> Processing item from executionList -> p = " + p); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> listItem.botPath = " + listItem.botPath); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Processing item from executionList -> p = " + p); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> listItem.botPath = " + listItem.botPath); }
/* File Path Root */
botConfig.filePathRoot = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> listItem.process = " + listItem.process); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> listItem.process = " + listItem.process); }
/* Now we loop throug all the configured processes at each bots configuration until we find the one we are supposed to run at this Node.js process. */
@@ -261,7 +263,7 @@ exports.newRoot = function newRoot() {
if (botConfig.processes[i].name === listItem.process) {
processFound = true;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> Process found at the bot configuration file. -> listItem.process = " + listItem.process); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Process found at the bot configuration file. -> listItem.process = " + listItem.process); }
let processConfig = botConfig.processes[i];
@@ -273,7 +275,7 @@ exports.newRoot = function newRoot() {
if (processConfig.startMode.allMonths.run === "true") {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> allMonths start mode detected. "); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> allMonths start mode detected. "); }
for (let year = processConfig.startMode.allMonths.maxYear; year >= processConfig.startMode.allMonths.minYear; year--) {
@@ -293,7 +295,7 @@ exports.newRoot = function newRoot() {
function startProcess() {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> startProcess -> Ready to start process."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> startProcess -> Ready to start process."); }
switch (botConfig.type) {
case 'Extraction': {
@@ -305,7 +307,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -318,13 +320,13 @@ exports.newRoot = function newRoot() {
if (processConfig.startMode.oneMonth.run === "true") {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> oneMonth start mode detected. "); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> oneMonth start mode detected. "); }
startProcess();
function startProcess() {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> startProcess -> Ready to start process."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> startProcess -> Ready to start process."); }
let month = pad(processConfig.startMode.oneMonth.month, 2);
let year = processConfig.startMode.oneMonth.year;
@@ -344,7 +346,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -374,7 +376,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -396,7 +398,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -423,7 +425,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -451,7 +453,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -476,29 +478,29 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
}
} catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected exception. -> err.message = " + err.message);
logger.write("[ERROR] start -> findProcess -> Unexpected exception. -> err.message = " + err.message);
}
}
}
if (processFound === false) {
logger.write("[ERROR] Root -> Process listed at the configuration file of AACloud not found at the configuration file of the bot. -> listItem.process = " + listItem.process);
logger.write("[ERROR] Process listed at the configuration file of AACloud not found at the configuration file of the bot. -> listItem.process = " + listItem.process);
}
function runExtractionBot(pBotConfig, pProcessConfig, pMonth, pYear) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> pYear = " + pYear); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> pYear = " + pYear); }
let extractionBotMainLoop = EXTRACTION_BOT_MAIN_LOOP_MODULE.newExtractionBotProcessMainLoop(pBotConfig);
extractionBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -520,16 +522,16 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
@@ -548,9 +550,9 @@ exports.newRoot = function newRoot() {
function runIndicatorBot(pBotConfig, pProcessConfig, pMonth, pYear) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> pYear = " + pYear); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> pYear = " + pYear); }
let indicatorBotMainLoop = INDICATOR_BOT_MAIN_LOOP_MODULE.newIndicatorBotProcessMainLoop(pBotConfig);
indicatorBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -572,23 +574,23 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> Bot will not be started. ");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> Bot will not be started. ");
}
}
}
@@ -600,7 +602,7 @@ exports.newRoot = function newRoot() {
function runTradingBot(pBotConfig, pProcessConfig) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runTradingBot -> Entering function."); }
let tradingBotMainLoop = TRADING_BOT_MAIN_LOOP_MODULE.newTradingBotProcessMainLoop(pBotConfig);
tradingBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -619,34 +621,34 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> Bot will not be started. ");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> Bot will not be started. ");
}
}
}
catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> err = " + err.message);
}
}
}
catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> err.message = " + err.message);
logger.write("[ERROR] start -> findProcess -> err.message = " + err.message);
return;
}
}