FULL_LOG refactoring

This commit is contained in:
Luis Fernando Molina committed 2018-03-07 19:40:22 +01:00
1 parent 0e110abee4
commit 14367c1746
9 files changed
+36 -36

No files matched your search

Binary file not shown.
+1 -1
View File
@@ -41,7 +41,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
/* Store local values. */
+4 -4
View File
@@ -37,7 +37,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
function initialize(pDataOwnerBotCodeName, callBackFunction) {
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
if (pDataOwnerBotCodeName === undefined) {
dataOwner = bot.codeName;
@@ -72,7 +72,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
function createFolder(pFolderPath, callBackFunction) {
if (LOG_INFO === true) { logger.write("[INFO] createFolder -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] createFolder -> Entering function."); }
if (fileService === undefined) {
@@ -165,7 +165,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
} else {
if (LOG_INFO === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); }
if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
}
}
@@ -234,7 +234,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
} else {
if (LOG_INFO === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); }
if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); }
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
}
}
+15 -14
View File
@@ -73,7 +73,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
/*
@@ -81,6 +81,7 @@
of the process.
*/
initializeStorage();
function initializeStorage() {
@@ -135,7 +136,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); }
/* If the process run and was interrupted, there should be a status report that allows us to resume execution. */
@@ -152,7 +153,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] initialize -> getStatusReport -> onFileReceived -> Content received = " + text);
}
@@ -190,7 +191,7 @@
function getExecutionHistory(callBack) {
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
let fileName = "Execution.History.json"
let filePath = EXCHANGE_NAME + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process;
@@ -205,7 +206,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] initialize -> getExecutionHistory -> onFileReceived -> Content received = " + text);
}
@@ -238,7 +239,7 @@
function getExecutionContext(callBack) {
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); }
let date = new Date(thisObject.statusReport.lastExecution);
@@ -256,7 +257,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] initialize -> getExecutionContext -> onFileReceived -> Content received = " + text);
}
@@ -290,7 +291,7 @@
function createConext(callBack) {
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); }
/*
When the bot is executed for the very first time, there are a few files that do not exist and need to be created, and that
@@ -364,7 +365,7 @@
function writeExecutionContext(callBack) {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function.");
}
@@ -398,7 +399,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
@@ -420,7 +421,7 @@
function writeExucutionHistory(callBack) {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function.");
}
@@ -463,7 +464,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
@@ -485,7 +486,7 @@
function writeStatusReport(callBack) {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeStatusReport -> Entering function.");
}
@@ -520,7 +521,7 @@
return;
}
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
+1 -1
View File
@@ -62,7 +62,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
initializeOliviaStorage();
+1 -1
View File
@@ -31,7 +31,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
let apiKey = readApiKey();
poloniexApiClient = new POLONIEX_CLIENT_MODULE(apiKey.Key, apiKey.Secret);
+4 -4
View File
@@ -4,7 +4,7 @@
const ROOT_DIR = './';
const MODULE_NAME = "Interval Executor";
const LOG_INFO = true;
const FULL_LOG = true;
let INTERVAL_MODULE;
@@ -79,13 +79,13 @@
if (year !== undefined) {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] Entering function 'start', with year = " + year + " and month = " + month);
}
} else {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
logger.write("[INFO] Entering function 'start'.");
}
@@ -109,7 +109,7 @@
try {
if (LOG_INFO === true) {
if (FULL_LOG === true) {
if (processConfig.intervalMaxLoops !== 0) {
+4 -4
View File
@@ -1,5 +1,5 @@
const LOG_INFO = true;
const FULL_LOG = true;
/* The following global variable tells the system if it is running on test mode or production. */
@@ -192,7 +192,7 @@ for (let i = 0; i < botConfig.processes.length; i++) {
function runTradingBot(pProcessConfig) {
try {
if (LOG_INFO === true) { logger.write("[INFO] runTradingBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] runTradingBot -> Entering function."); }
let tradingBot = TRADING_BOT_MODULE.newTradingBot(botConfig);
tradingBot.initialize(vmConfig.bot.path, pProcessConfig, onInitializeReady);
@@ -203,9 +203,9 @@ function runTradingBot(pProcessConfig) {
tradingBot.start(whenStartFinishes);
function whenStartFinishes() {
function whenStartFinishes(err) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] trading bot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
+6 -7
View File
@@ -4,7 +4,7 @@
const ROOT_DIR = './';
const MODULE_NAME = "Trading Bot";
const LOG_INFO = true;
const FULL_LOG = true;
let USER_BOT_MODULE;
@@ -25,7 +25,7 @@
function initialize(pBotPath, pProcessConfig, callBackFunction) {
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
processConfig = pProcessConfig;
USER_BOT_MODULE = require(pBotPath + "/" + pProcessConfig.name + "/" + 'User.Bot');
@@ -41,20 +41,19 @@
function start(callBackFunction) {
try {
if (LOG_INFO === true) { logger.write("[INFO] start -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> Entering function."); }
loop();
function loop() {
try {
if (LOG_INFO === true) { logger.write("[INFO] start -> loop -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> loop -> Entering function."); }
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
const UTILITIES = require(ROOT_DIR + 'Utilities');
const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage');
const MARKETS_MODULE = require(ROOT_DIR + 'Markets');
const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log');
const POLONIEX_CLIENT_MODULE = require(ROOT_DIR + 'Poloniex API Client');
const EXCHANGE_API = require(ROOT_DIR + 'ExchangeAPI');
@@ -223,12 +222,12 @@
switch (nextWaitTime) {
case 'Normal': {
if (LOG_INFO === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); }
setTimeout(loop, processConfig.executionWaitTime);
}
break;
case 'Retry': {
if (LOG_INFO === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
setTimeout(loop, processConfig.retryWaitTime);
}
break;