Debug Log to File System Eliminated
This commit is contained in:
1 parent
0f3b3f63a3
commit
472ef87f88
9 files changed
+192
-447
No files matched your search
+158
-116
@@ -7,7 +7,7 @@ exports.newBlobStorage = function newBlobStorage(BOT) {
|
||||
let bot = BOT;
|
||||
const ROOT_DIR = './';
|
||||
|
||||
const MODULE_NAME = "Blob Storage";
|
||||
const MODULE_NAME = "BlobStorage";
|
||||
|
||||
let storage = require('azure-storage');
|
||||
|
||||
@@ -116,57 +116,78 @@ exports.newBlobStorage = function newBlobStorage(BOT) {
|
||||
|
||||
function onFileCreated(err, result, response) {
|
||||
|
||||
if (FULL_LOG === true) {
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> Response from Azure received.");
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
}
|
||||
try {
|
||||
|
||||
if (err) {
|
||||
if (FULL_LOG === true) {
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> Response from Azure received.");
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
}
|
||||
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
if (err) {
|
||||
|
||||
if (err.code === 'ServerBusy'
|
||||
|| err.code === 'ECONNRESET'
|
||||
|| err.code === 'ENOTFOUND'
|
||||
|| err.code === 'ESOCKETTIMEDOUT'
|
||||
|| err.code === 'ETIMEDOUT'
|
||||
|| err.code === 'ECONNREFUSED'
|
||||
|| (err.code === 'AuthenticationFailed' && err.authenticationerrordetail.indexOf('Request date header too old') === 0)
|
||||
|| err.code === 'OperationTimedOut'
|
||||
|| err.code === 'EADDRINUSE') {
|
||||
|
||||
setTimeout(secondTry, 1000);
|
||||
return;
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
|
||||
function secondTry() {
|
||||
if (err.code === 'ServerBusy'
|
||||
|| err.code === 'ECONNRESET'
|
||||
|| err.code === 'ENOTFOUND'
|
||||
|| err.code === 'ESOCKETTIMEDOUT'
|
||||
|| err.code === 'ETIMEDOUT'
|
||||
|| err.code === 'ECONNREFUSED'
|
||||
|| (err.code === 'AuthenticationFailed' && err.authenticationerrordetail.indexOf('Request date header too old') === 0)
|
||||
|| err.code === 'OperationTimedOut'
|
||||
|| err.code === 'EADDRINUSE') {
|
||||
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> secondTry -> Retrying to create the file.");
|
||||
setTimeout(secondTry, 1000);
|
||||
return;
|
||||
|
||||
writeOnlyBlobService.createBlockBlobFromText(containerName, pFolderPath + "/" + pFileName, pFileContent, onSecondTry);
|
||||
function secondTry() {
|
||||
|
||||
function onSecondTry(err, result, response) {
|
||||
try {
|
||||
|
||||
if (err) {
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> secondTry -> File not created. Giving Up.");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
} else {
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> secondTry -> File succesfully created on second try.");
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> secondTry -> Retrying to create the file.");
|
||||
|
||||
writeOnlyBlobService.createBlockBlobFromText(containerName, pFolderPath + "/" + pFileName, pFileContent, onSecondTry);
|
||||
|
||||
function onSecondTry(err, result, response) {
|
||||
|
||||
try {
|
||||
|
||||
if (err) {
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> secondTry -> File not created. Giving Up.");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
} else {
|
||||
logger.write("[INFO] createTextFile -> onFileCreated -> secondTry -> File succesfully created on second try.");
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'createTextFile' -> onFileCreated -> secondTry -> onSecondTry -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'createTextFile' -> onFileCreated -> secondTry -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> Dont know what to do here. Cancelling operation. ");
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
} else {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); }
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> Dont know what to do here. Cancelling operation. ");
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'createTextFile' -> onFileCreated -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
} else {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> onFileCreated -> File Created."); }
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,98 +219,119 @@ exports.newBlobStorage = function newBlobStorage(BOT) {
|
||||
|
||||
function onFileReceived(err, text, response) {
|
||||
|
||||
if (FULL_LOG === true) {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> Response from Azure received.");
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> err = " + JSON.stringify(err));
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> response = " + JSON.stringify(response));
|
||||
}
|
||||
try {
|
||||
|
||||
if (LOG_FILE_CONTENT === true) {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> text = " + text);
|
||||
}
|
||||
if (FULL_LOG === true) {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> Response from Azure received.");
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> err = " + JSON.stringify(err));
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> response = " + JSON.stringify(response));
|
||||
}
|
||||
|
||||
if (err) {
|
||||
if (LOG_FILE_CONTENT === true) {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> text = " + text);
|
||||
}
|
||||
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
if (err) {
|
||||
|
||||
if (err.code === 'ServerBusy'
|
||||
|| err.code === 'ECONNRESET'
|
||||
|| err.code === 'ENOTFOUND'
|
||||
|| err.code === 'ESOCKETTIMEDOUT'
|
||||
|| err.code === 'ETIMEDOUT'
|
||||
|| err.code === 'ECONNREFUSED'
|
||||
|| (err.code === 'AuthenticationFailed' && err.authenticationerrordetail.indexOf('Request date header too old') === 0)
|
||||
|| err.code === 'OperationTimedOut'
|
||||
|| err.code === 'EADDRINUSE') {
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> err = " + JSON.stringify(err));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
|
||||
logger.write("[ERROR] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
|
||||
|
||||
setTimeout(secondTry, 1000);
|
||||
return;
|
||||
if (err.code === 'ServerBusy'
|
||||
|| err.code === 'ECONNRESET'
|
||||
|| err.code === 'ENOTFOUND'
|
||||
|| err.code === 'ESOCKETTIMEDOUT'
|
||||
|| err.code === 'ETIMEDOUT'
|
||||
|| err.code === 'ECONNREFUSED'
|
||||
|| (err.code === 'AuthenticationFailed' && err.authenticationerrordetail.indexOf('Request date header too old') === 0)
|
||||
|| err.code === 'OperationTimedOut'
|
||||
|| err.code === 'EADDRINUSE') {
|
||||
|
||||
function secondTry() {
|
||||
setTimeout(secondTry, 1000);
|
||||
return;
|
||||
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> secondTry -> Retrying to get the file.");
|
||||
function secondTry() {
|
||||
|
||||
readOnlyBlobService.getBlobToText(containerName, pFolderPath + "/" + pFileName, onSecondTry);
|
||||
try {
|
||||
|
||||
function onSecondTry(err, text, response) {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> secondTry -> Retrying to get the file.");
|
||||
|
||||
if (err) {
|
||||
logger.write("[ERROR] getTextFile -> onFileReceived -> secondTry -> File not retrieved. Giving Up.");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
} else {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> secondTry -> File succesfully retrieved on second try.");
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
|
||||
readOnlyBlobService.getBlobToText(containerName, pFolderPath + "/" + pFileName, onSecondTry);
|
||||
|
||||
function onSecondTry(err, text, response) {
|
||||
|
||||
try {
|
||||
|
||||
if (err) {
|
||||
logger.write("[ERROR] getTextFile -> onFileReceived -> secondTry -> File not retrieved. Giving Up.");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
} else {
|
||||
logger.write("[INFO] getTextFile -> onFileReceived -> secondTry -> File succesfully retrieved on second try.");
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'getTextFile' -> onFileReceived -> secondTry -> onSecondTry -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'getTextFile' -> onFileReceived -> secondTry -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (err.code === "BlobNotFound") {
|
||||
|
||||
/* This is how Azure tell us the file does not exist. */
|
||||
|
||||
let customErr = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "File does not exist."
|
||||
};
|
||||
|
||||
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
|
||||
logger.write("[WARN] getTextFile -> containerName = " + containerName);
|
||||
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
|
||||
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
|
||||
|
||||
callBackFunction(customErr);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (err.code === "ParentNotFound") {
|
||||
|
||||
/* This is how Azure tell us the folder where the file was supposed to be does not exist. We map this to our own response. */
|
||||
|
||||
let customErr = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "Folder does not exist."
|
||||
};
|
||||
|
||||
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
|
||||
logger.write("[WARN] getTextFile -> containerName = " + containerName);
|
||||
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
|
||||
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
|
||||
|
||||
callBackFunction(customErr);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
logger.write("[ERROR] getTextFile -> onFileReceived -> Dont know what to do here. Cancelling operation. ");
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
} else {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); }
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
|
||||
}
|
||||
|
||||
if (err.code === "BlobNotFound") {
|
||||
|
||||
/* This is how Azure tell us the file does not exist. */
|
||||
|
||||
let customErr = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "File does not exist."
|
||||
};
|
||||
|
||||
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
|
||||
logger.write("[WARN] getTextFile -> containerName = " + containerName);
|
||||
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
|
||||
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
|
||||
|
||||
callBackFunction(customErr);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (err.code === "ParentNotFound") {
|
||||
|
||||
/* This is how Azure tell us the folder where the file was supposed to be does not exist. We map this to our own response. */
|
||||
|
||||
let customErr = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "Folder does not exist."
|
||||
};
|
||||
|
||||
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
|
||||
logger.write("[WARN] getTextFile -> containerName = " + containerName);
|
||||
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
|
||||
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
|
||||
|
||||
callBackFunction(customErr);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
logger.write("[ERROR] getTextFile -> onFileReceived -> Dont know what to do here. Cancelling operation. ");
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] 'getTextFile' -> onFileReceived -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
} else {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> onFileReceived -> File retrieved."); }
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
|
||||
const MODULE_NAME = "Cloud Require";
|
||||
const MODULE_NAME = "CloudRequire";
|
||||
|
||||
let bot = BOT;
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
|
||||
const MODULE_NAME = "Data Dependencies";
|
||||
const MODULE_NAME = "DataDependencies";
|
||||
|
||||
let bot = BOT;
|
||||
let ownerBot; // This is the bot owner of the Data Set.
|
||||
|
||||
+28
-244
@@ -1,20 +1,16 @@
|
||||
exports.newDebugLog = function newDebugLog() {
|
||||
|
||||
const ROOT_DIR = './';
|
||||
const MODULE_NAME = "Debug Log";
|
||||
const fileSystem = require('fs');
|
||||
const MODULE_NAME = "DebugLog";
|
||||
|
||||
const currentDate = new Date();
|
||||
const dateString = currentDate.getUTCFullYear() + '-' + pad(currentDate.getUTCMonth() + 1, 2) + '-' + pad(currentDate.getUTCDate(), 2) + '-' + pad(currentDate.getUTCHours(), 2) + '-' + pad(currentDate.getUTCMinutes(), 2);
|
||||
const randomId = parseInt(Math.random() * 1000000);
|
||||
let executionDatetime = global.EXECUTION_DATETIME.getUTCFullYear() +
|
||||
"/" + pad(global.EXECUTION_DATETIME.getUTCMonth() + 1, 2) +
|
||||
"/" + pad(global.EXECUTION_DATETIME.getUTCDate(), 2) +
|
||||
"/" + pad(global.EXECUTION_DATETIME.getUTCHours(),2) +
|
||||
"/" + pad(global.EXECUTION_DATETIME.getUTCMinutes(),2) +
|
||||
"/" + pad(global.EXECUTION_DATETIME.getUTCSeconds(),2);
|
||||
|
||||
let executionDatetime = global.EXECUTION_DATETIME.toISOString();
|
||||
let executionPath = global.EXECUTION_DATETIME.getUTCFullYear() + '-' + pad(global.EXECUTION_DATETIME.getUTCMonth() + 1, 2) + '-' + pad(global.EXECUTION_DATETIME.getUTCDate(), 2) + 'T' + pad(global.EXECUTION_DATETIME.getUTCHours(), 2) + '-' + pad(global.EXECUTION_DATETIME.getUTCMinutes(), 2) + '-' + pad(global.EXECUTION_DATETIME.getUTCSeconds(), 2);
|
||||
|
||||
let fileNumber = 1;
|
||||
let messageId = 0;
|
||||
let firstCall = true;
|
||||
let folderPath;
|
||||
let loopCounter;
|
||||
let loopIncremented = false;
|
||||
|
||||
@@ -70,150 +66,54 @@
|
||||
function onFileCreated(err) {
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log("[ERROR] onLoopFinished -> onInizialized -> onFileCreated -> err = " + err.message);
|
||||
console.log("[ERROR] Debug-Log -> onLoopFinished -> onInizialized -> onFileCreated -> err = " + err.message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("[ERROR] onLoopFinished -> onInizialized -> err = " + err.message);
|
||||
console.log("[ERROR] Debug-Log -> onLoopFinished -> onInizialized -> err = " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log("[ERROR] onLoopFinished -> err = " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function createFolders() {
|
||||
|
||||
try {
|
||||
|
||||
folderPath = '../Logs';
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
firstCall = false;
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
console.log("Error trying to create the folders needed. Error: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function createLoopFolder() {
|
||||
|
||||
try {
|
||||
|
||||
if (thisObject.bot.debug.year !== undefined) {
|
||||
|
||||
/* When there are YEARS and MONTHS involved */
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/" + thisObject.bot.debug.year;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/" + thisObject.bot.debug.year + "/" + thisObject.bot.debug.month;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
/* Loop folder creation and mantainance. */
|
||||
|
||||
/* We create the new one. */
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/" + thisObject.bot.debug.year + "/" + thisObject.bot.debug.month + "/Loop." + loopCounter;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
/* We also remove old folders according to the configuration value of global.PLATFORM_CONFIG.maxLogLoops. */
|
||||
|
||||
let folderToRemove = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/" + thisObject.bot.debug.year + "/" + thisObject.bot.debug.month + "/Loop." + (loopCounter - global.PLATFORM_CONFIG.maxLogLoops).toString();
|
||||
|
||||
deleteLoopFolder(folderToRemove);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
/* When there are no YEARS or MONTHS involved */
|
||||
|
||||
/* We create the new one. */
|
||||
|
||||
folderPath = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/Loop." + loopCounter;
|
||||
|
||||
createFolderSync(folderPath);
|
||||
|
||||
/* We also remove old folders according to the configuration value of global.PLATFORM_CONFIG.maxLogLoops. */
|
||||
|
||||
let folderToRemove = '../Logs/' + executionPath + "/" + thisObject.bot.devTeam + "/" + thisObject.bot.type + "/" + thisObject.bot.codeName + "." + thisObject.bot.version.major + "." + thisObject.bot.version.minor + "/" + thisObject.bot.process + "/Loop." + (loopCounter - global.PLATFORM_CONFIG.maxLogLoops).toString();
|
||||
|
||||
deleteLoopFolder(folderToRemove);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log("Error trying to create the loop folder needed or deleting old ones. Error: " + err.message);
|
||||
console.log("[ERROR] Debug-Log -> onLoopFinished -> err = " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function write(Message) {
|
||||
|
||||
if (thisObject.bot === undefined) { return;}
|
||||
try {
|
||||
|
||||
console.log("AACloud" + spacePad(thisObject.fileName, 50) + " : " + Message);
|
||||
console.log("AACloud" + spacePad(thisObject.fileName, 50) + " : " + Message);
|
||||
|
||||
if (thisObject.bot === undefined) { return;}
|
||||
if (thisObject.bot === undefined) { return; }
|
||||
|
||||
if (firstCall === true && global.CURRENT_EXECUTION_AT === "Cloud") { createFolders(); }
|
||||
if (thisObject.bot.loopCounter !== loopCounter) {
|
||||
|
||||
if (thisObject.bot.loopCounter !== loopCounter) {
|
||||
if (thisObject.forceLoopSplit === false) {
|
||||
|
||||
if (thisObject.forceLoopSplit === false) {
|
||||
if (loopIncremented === false) {
|
||||
|
||||
if (loopIncremented === false) {
|
||||
loopIncremented = true;
|
||||
|
||||
loopCounter = thisObject.bot.loopCounter;
|
||||
|
||||
blobContent = "[";
|
||||
}
|
||||
} else {
|
||||
|
||||
loopIncremented = true;
|
||||
|
||||
loopCounter = thisObject.bot.loopCounter;
|
||||
createLoopFolder();
|
||||
blobContent = "[";
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
loopIncremented = true;
|
||||
|
||||
loopCounter = thisObject.bot.loopCounter;
|
||||
createLoopFolder();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let filePath = getCurrentLogFile(folderPath + "/" + dateString + "---" + randomId + "---", thisObject.fileName);
|
||||
let newDate = new Date();
|
||||
newDate = newDate.toISOString();
|
||||
|
||||
let newDate = new Date();
|
||||
newDate = newDate.toISOString();
|
||||
|
||||
messageId++;
|
||||
|
||||
try {
|
||||
messageId++;
|
||||
|
||||
let line = {
|
||||
date: newDate,
|
||||
@@ -223,8 +123,6 @@
|
||||
|
||||
let fileLine = '\r\n' + JSON.stringify(line);
|
||||
|
||||
fileSystem.appendFileSync(filePath, fileLine);
|
||||
|
||||
if (blobContent === "[") {
|
||||
|
||||
blobContent = blobContent + fileLine;
|
||||
@@ -233,62 +131,11 @@
|
||||
|
||||
blobContent = blobContent + "," + fileLine;
|
||||
}
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
//console.log("Error trying to log info into a file.");
|
||||
//console.log("File: " + filePath );
|
||||
//console.log("Error: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function createFolderSync(name) {
|
||||
try {
|
||||
fileSystem.mkdirSync( name)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EEXIST') throw err
|
||||
console.log("[ERROR] Debug-Log -> write -> err = " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentLogFile(relativePath, fileName) {
|
||||
|
||||
let filePath;
|
||||
let stats;
|
||||
let i;
|
||||
|
||||
try {
|
||||
for (i = 1; i < 1000000; i++) {
|
||||
|
||||
filePath = relativePath + i + "." + fileName + '.log';
|
||||
stats = fileSystem.statSync(filePath);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
if (i > 1) {
|
||||
|
||||
filePath = relativePath + (i - 1) + "." + fileName + '.log';
|
||||
|
||||
stats = fileSystem.statSync(filePath);
|
||||
const fileSizeInBytes = stats.size;
|
||||
|
||||
if (fileSizeInBytes > 10240000) {
|
||||
|
||||
filePath = relativePath + i + "." + fileName + '.log';
|
||||
}
|
||||
|
||||
return filePath;
|
||||
|
||||
} else {
|
||||
|
||||
return filePath;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pad(str, max) {
|
||||
str = str.toString();
|
||||
return str.length < max ? pad("0" + str, max) : str;
|
||||
@@ -299,68 +146,5 @@
|
||||
return str.length < max ? spacePad(" " + str, max) : str;
|
||||
}
|
||||
|
||||
function deleteLoopFolder(pFolderPath) {
|
||||
|
||||
let fs = require('fs');
|
||||
let errosFound = false;
|
||||
|
||||
try {
|
||||
|
||||
let fileCount;
|
||||
let filesChecked = 0;
|
||||
|
||||
fs.readdir(pFolderPath, onfileCount);
|
||||
|
||||
function onfileCount(err, files) {
|
||||
|
||||
if (err) { return; }
|
||||
|
||||
try {
|
||||
fileCount = files.length;
|
||||
|
||||
fs.readdirSync(pFolderPath).forEach(fileName => {
|
||||
|
||||
fs.readFile(pFolderPath + "/" + fileName, onFileRead);
|
||||
|
||||
function onFileRead(err, file) {
|
||||
|
||||
try {
|
||||
|
||||
filesChecked++;
|
||||
|
||||
if (file.indexOf("[ERROR]") > 0) {
|
||||
|
||||
errosFound = true;
|
||||
|
||||
}
|
||||
|
||||
if (filesChecked === fileCount) {
|
||||
|
||||
if (errosFound === false) {
|
||||
|
||||
let rimraf = require('rimraf');
|
||||
rimraf.sync(pFolderPath);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// We ignore the error;
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
catch (err) {
|
||||
// We ignore the error;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// We ignore the error;
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
let bot = BOT;
|
||||
const ROOT_DIR = './';
|
||||
|
||||
const MODULE_NAME = "Extraction Bot Process Main Loop";
|
||||
const MODULE_NAME = "ExtractionBotProcessMainLoop";
|
||||
const FULL_LOG = true;
|
||||
|
||||
let USER_BOT_MODULE;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
let bot = BOT;
|
||||
const ROOT_DIR = './';
|
||||
|
||||
const MODULE_NAME = "Indicator Bot Process Main Loop";
|
||||
const MODULE_NAME = "IndicatorBotProcessMainLoop";
|
||||
const FULL_LOG = true;
|
||||
|
||||
let USER_BOT_MODULE;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
|
||||
const MODULE_NAME = "Status Dependencies";
|
||||
const MODULE_NAME = "StatusDependencies";
|
||||
|
||||
let thisObject = {
|
||||
statusReports: new Map(),
|
||||
|
||||
Generated
-80
@@ -101,11 +101,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
|
||||
@@ -123,15 +118,6 @@
|
||||
"hoek": "4.2.1"
|
||||
}
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"browserify-mime": {
|
||||
"version": "1.2.9",
|
||||
"resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz",
|
||||
@@ -155,11 +141,6 @@
|
||||
"delayed-stream": "1.0.0"
|
||||
}
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
@@ -240,11 +221,6 @@
|
||||
"mime-types": "2.1.18"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
|
||||
@@ -253,19 +229,6 @@
|
||||
"assert-plus": "1.0.0"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"requires": {
|
||||
"fs.realpath": "1.0.0",
|
||||
"inflight": "1.0.6",
|
||||
"inherits": "2.0.3",
|
||||
"minimatch": "3.0.4",
|
||||
"once": "1.4.0",
|
||||
"path-is-absolute": "1.0.1"
|
||||
}
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
||||
@@ -315,15 +278,6 @@
|
||||
"sshpk": "1.14.1"
|
||||
}
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "1.4.0",
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
@@ -411,32 +365,11 @@
|
||||
"mime-db": "1.33.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "1.1.11"
|
||||
}
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
|
||||
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
@@ -470,14 +403,6 @@
|
||||
"util-deprecate": "1.0.2"
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
|
||||
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
|
||||
"requires": {
|
||||
"glob": "7.1.2"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
@@ -568,11 +493,6 @@
|
||||
"extsprintf": "1.3.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"xml2js": {
|
||||
"version": "0.2.8",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz",
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@
|
||||
"author": "Luis-Fernando-Molina",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"azure-storage": "^2.8.2",
|
||||
"rimraf": "^2.6.2"
|
||||
"azure-storage": "^2.8.2"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user