From dba159af7aae19f49106f5bfb2b00108db96e64a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 17 Oct 2019 10:20:48 +0200 Subject: [PATCH] SESSION.folderName implemented --- Context.js | 2 +- DebugLog.js | 6 +----- MultiPeriod.js | 2 +- Session.js | 26 ++++++++++++++++++++++++-- StatusReport.js | 2 +- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Context.js b/Context.js index 3880cb649..5395ac2ca 100644 --- a/Context.js +++ b/Context.js @@ -84,7 +84,7 @@ statusDependencies = pStatusDependencies; if (bot.SESSION !== undefined) { - sessionPath = bot.SESSION.id + "/" + sessionPath = bot.SESSION.folderName + "/" } /* diff --git a/DebugLog.js b/DebugLog.js index e996fe4dd..06b40a94e 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -69,11 +69,7 @@ exports.newDebugLog = function newDebugLog() { let filePath = thisObject.bot.filePathRoot + "/Logs/" + thisObject.bot.process + "/" if (thisObject.bot.SESSION !== undefined) { - if (thisObject.bot.SESSION.code.folderName === undefined) { - filePath = filePath + thisObject.bot.SESSION.id + "/" + executionDatetime; - } else { - filePath = filePath + thisObject.bot.SESSION.code.folderName + "/" + executionDatetime; - } + filePath = filePath + thisObject.bot.SESSION.folderName + "/" + executionDatetime; } else { filePath = filePath + executionDatetime; } diff --git a/MultiPeriod.js b/MultiPeriod.js index 2c31ec399..f3c183383 100644 --- a/MultiPeriod.js +++ b/MultiPeriod.js @@ -986,7 +986,7 @@ let fileContent = JSON.stringify(dataRange); let fileName = '/Data.Range.' + market.assetA + '_' + market.assetB + '.json'; - let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.id + "/" + pProductFolder + "/" + 'Multi-Period-Daily' + fileName; + let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + pProductFolder + "/" + 'Multi-Period-Daily' + fileName; fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); diff --git a/Session.js b/Session.js index 181a0b726..70d00ae53 100644 --- a/Session.js +++ b/Session.js @@ -14,12 +14,19 @@ if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); } /* Initialize this info so that everything is logged propeerly */ + bot.SESSION = { name: bot.processNode.session.name, - id: bot.processNode.session.id, - code: bot.processNode.session.code + id: bot.processNode.session.id } + /* Set the folderName for early logging */ + if (bot.processNode.session.code.folderName === undefined) { + bot.SESSION.folderName = bot.SESSION.id + } else { + bot.SESSION.folderName = bot.processNode.session.code.folderName + } + /* Check if there is a session */ if (bot.processNode.session === undefined) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session."); @@ -40,6 +47,21 @@ bot.SESSION = JSON.parse(message.event.session) bot.UI_CURRENT_VALUES = message.event.uiCurrentValues + /* Set the folderName for logging, reports, context and data output */ + let code + if (bot.SESSION.code !== undefined) { + try { + code = JSON.parse(bot.SESSION.code) + if (code.folderName === undefined) { + bot.SESSION.folderName = bot.SESSION.id + } else { + bot.SESSION.folderName = bot.processNode.session.code.folderName + } + } catch (err) { + bot.SESSION.folderName = bot.SESSION.id + } + } + setValuesToUse(message) switch (bot.SESSION.type) { diff --git a/StatusReport.js b/StatusReport.js index 65a6916e2..4096976a4 100644 --- a/StatusReport.js +++ b/StatusReport.js @@ -51,7 +51,7 @@ year = pYear; if (bot.SESSION !== undefined && pOwner.type === "Trading Engine") { - sessionPath = bot.SESSION.id + "/" + sessionPath = bot.SESSION.folderName + "/" } if (owner.dataSetSection === "Month") {