diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 4d0292519..2b00efbff 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -367,6 +367,12 @@ "propertyName": "nodeJSConstants", "functionName": "newSuperalgosGlobalsNodeJSConstants", "fileName": "NodeJSConstants.js" + }, + { + "name": "Logger Variables", + "propertyName": "loggerVariables", + "functionName": "newSuperalgosGlobalsLoggerVariables", + "fileName": "LoggerVariables.js" } ], "functionLibraries": [ diff --git a/Projects/Superalgos/TS/Globals/LoggerVariables.js b/Projects/Superalgos/TS/Globals/LoggerVariables.js new file mode 100644 index 000000000..b4b041dbf --- /dev/null +++ b/Projects/Superalgos/TS/Globals/LoggerVariables.js @@ -0,0 +1,7 @@ +exports.newSuperalgosGlobalsLoggerVariables = function () { + let thisObject = { + DELETE_QUEUE_SIZE: 10 + } + + return thisObject +} \ No newline at end of file diff --git a/Projects/Superalgos/TS/Globals/ProcessVariables.js b/Projects/Superalgos/TS/Globals/ProcessVariables.js index ebaad4620..080433876 100644 --- a/Projects/Superalgos/TS/Globals/ProcessVariables.js +++ b/Projects/Superalgos/TS/Globals/ProcessVariables.js @@ -6,7 +6,8 @@ exports.newSuperalgosGlobalsProcessVariables = function () { */ let thisObject = { ENDED_PROCESSES_COUNTER: 0, - TOTAL_PROCESS_INSTANCES_CREATED: 0 + TOTAL_PROCESS_INSTANCES_CREATED: 0, + VARIABLES_BY_PROCESS_INDEX_MAP: new Map() } return thisObject diff --git a/TaskServer/DebugLog.js b/TaskServer/DebugLog.js index 3aac2ab28..78fea95d5 100644 --- a/TaskServer/DebugLog.js +++ b/TaskServer/DebugLog.js @@ -112,11 +112,6 @@ exports.newDebugLog = function (processIndex) { } } - if (thisObject.bot.debug.year !== undefined) { - - filePath = filePath + "/" + thisObject.bot.debug.year + "/" + thisObject.bot.debug.month; - } - let fileName; if (internalLoopCounter >= 0) { fileName = "Loop." + pad(thisObject.bot.loopCounter, 8) + "." + pad(internalLoopCounter, 4) + ".json"; @@ -128,11 +123,11 @@ exports.newDebugLog = function (processIndex) { /* This is the implementation of the mechanism to auto-mantain logs. */ if (contentToPersist.indexOf('[ERROR]') < 0 && contentToPersist.indexOf('[PERSIST]') < 0 && contentToPersist.indexOf('[IMPORTANT]') < 0) { - thisObject.bot.LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName) + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName) } - if (thisObject.bot.LOGS_TO_DELETE_QUEUE.length > thisObject.bot.DELETE_QUEUE_SIZE) { - let fileToDelete = thisObject.bot.LOGS_TO_DELETE_QUEUE[0] - thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0, 1) + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE.length > TS.projects.superalgos.globals.loggerVariables.DELETE_QUEUE_SIZE) { + let fileToDelete = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE[0] + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE.splice(0, 1) /* Will delete this file only if it does not contains ERROR inside. */ let fileContent = fileStorage.getTextFile(fileToDelete, onGetFile, true) function onGetFile(err, fileContent) { diff --git a/TaskServer/ProcessInstance.js b/TaskServer/ProcessInstance.js index ebcdcd816..02b01a011 100644 --- a/TaskServer/ProcessInstance.js +++ b/TaskServer/ProcessInstance.js @@ -32,11 +32,7 @@ TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set('Pre-Bot-Main-Loop' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger) logger.bot = botConfig; - botConfig.debug = {}; - - /* Logs Mantainance Stuff */ - botConfig.LOGS_TO_DELETE_QUEUE = [] - botConfig.DELETE_QUEUE_SIZE = 10 // This number represents how many log files can be at the queue at any point in time, which means how many logs are not still deleted. + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.set(processIndex, {LOGS_TO_DELETE_QUEUE: []}) /* Loop Counter */ botConfig.loopCounter = 0;