From 53006f707b9441aa7259c83898ab0973c96b73ec Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 1 Dec 2020 15:43:39 +0100 Subject: [PATCH] moved to logger variables --- Projects/Superalgos/TS/Globals/LoggerVariables.js | 3 ++- Projects/Superalgos/TS/Globals/ProcessVariables.js | 1 - TaskServer/DebugLog.js | 8 ++++---- TaskServer/ProcessInstance.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Projects/Superalgos/TS/Globals/LoggerVariables.js b/Projects/Superalgos/TS/Globals/LoggerVariables.js index 651f1d965..a1b3bbce9 100644 --- a/Projects/Superalgos/TS/Globals/LoggerVariables.js +++ b/Projects/Superalgos/TS/Globals/LoggerVariables.js @@ -11,7 +11,8 @@ exports.newSuperalgosGlobalsLoggerVariables = function () { PROCESS_INSTANCE_LOGGER_MODULE This is the logger module used by the process instance. BOT_MAIN_LOOP_LOGGER_MODULE This is the logger module instantiated at every main loop and used at downstream modules. - + LOGS_TO_DELETE_QUEUE This stores the logs that need to be deleted, for auto mantainance. + */ 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 944d58d11..31c72dab0 100644 --- a/Projects/Superalgos/TS/Globals/ProcessVariables.js +++ b/Projects/Superalgos/TS/Globals/ProcessVariables.js @@ -20,7 +20,6 @@ exports.newSuperalgosGlobalsProcessVariables = function () { SESSION_KEY This is the key used in events related to the Session SESSION_FOLDER_NAME This is the folder name for Session related data and logs. MAIN_LOOP_COUNTER This is the counter of main loops for a bot process. - LOGS_TO_DELETE_QUEUE This stores the logs that need to be deleted, for auto mantainance. SOCIAL_BOTS_MODULE This is the module that controls social bots. SESSION_STATUS This tell us the status of the session at any given time. IS_SESSION_STOPPING This tell us if a session is in the process of being stopped. diff --git a/TaskServer/DebugLog.js b/TaskServer/DebugLog.js index 7ce7b2a0a..12492c1f4 100644 --- a/TaskServer/DebugLog.js +++ b/TaskServer/DebugLog.js @@ -115,11 +115,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) { - TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName) } - 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) + if (TS.projects.superalgos.globals.loggerVariables.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.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).LOGS_TO_DELETE_QUEUE[0] + TS.projects.superalgos.globals.loggerVariables.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 0e88a42ad..38c72cd71 100644 --- a/TaskServer/ProcessInstance.js +++ b/TaskServer/ProcessInstance.js @@ -29,6 +29,7 @@ We will use a logger for what happens before and after the bot main loop. */ VARIABLES_BY_PROCESS_INDEX = { + LOGS_TO_DELETE_QUEUE: [], PROCESS_INSTANCE_LOGGER_MODULE: DEBUG_MODULE.newDebugLog(processIndex) } TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.set(processIndex, VARIABLES_BY_PROCESS_INDEX) @@ -39,7 +40,6 @@ accesed from where it is needed. */ VARIABLES_BY_PROCESS_INDEX = { - LOGS_TO_DELETE_QUEUE: [], MAIN_LOOP_COUNTER: 0, PROCESS_KEY: TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].name + '-' +