From 8b0bb914d4242785a09bbb4e593a52fd6c78469a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 10:40:22 +0200 Subject: [PATCH 1/6] minor --- .../client/source/class/osparc/data/model/Node.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Node.js b/services/static-webserver/client/source/class/osparc/data/model/Node.js index 65ff7ae20dd1..715896b3c167 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Node.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Node.js @@ -1225,7 +1225,8 @@ qx.Class.define("osparc.data.model.Node", { const msg = "Starting " + metaData.key + ":" + metaData.version + "..."; const msgData = { nodeId: this.getNodeId(), - msg: msg + msg, + level: "INFO" }; this.fireDataEvent("showInLogger", msgData); @@ -1242,7 +1243,8 @@ qx.Class.define("osparc.data.model.Node", { const msg = "Stopping " + metaData.key + ":" + metaData.version + "..."; const msgData = { nodeId: this.getNodeId(), - msg: msg + msg: msg, + level: "INFO" }; this.fireDataEvent("showInLogger", msgData); @@ -1278,7 +1280,8 @@ qx.Class.define("osparc.data.model.Node", { `reported "${serviceMessage}"`; const msgData = { nodeId: this.getNodeId(), - msg: msg + msg: msg, + level: "INFO" }; this.fireDataEvent("showInLogger", msgData); } @@ -1446,7 +1449,8 @@ qx.Class.define("osparc.data.model.Node", { const msg = "Service ready on " + srvUrl; const msgData = { nodeId: this.getNodeId(), - msg: msg + msg, + level: "INFO" }; this.fireDataEvent("showInLogger", msgData); this.__restartIFrame(); From 6f24a05dbb0706d72b7d42e220fff3472a9e832b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 10:46:45 +0200 Subject: [PATCH 2/6] minor --- .../class/osparc/desktop/WorkbenchView.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js index 0087141b3c61..341bdfdef965 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js +++ b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js @@ -597,10 +597,20 @@ qx.Class.define("osparc.desktop.WorkbenchView", { const data = e.getData(); const nodeId = data.nodeId; const msg = data.msg; - if ("level" in data && data["level"] === "ERROR") { - this.__loggerView.error(nodeId, msg); - } else { - this.__loggerView.info(nodeId, msg); + const logLevel = ("level" in data) ? data["level"] : "INFO"; + switch (logLevel) { + case "DEBUG": + this.__loggerView.debug(nodeId, msg); + break; + case "WARNING": + this.__loggerView.warn(nodeId, msg); + break; + case "ERROR": + this.__loggerView.error(nodeId, msg); + break; + default: + this.__loggerView.info(nodeId, msg); + break; } }, this); From 8a42a3f620d777e8b87a9ed5c95c212159953493 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 11:08:11 +0200 Subject: [PATCH 3/6] minors --- .../component/widget/logger/LoggerTable.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js index 01508ab7de36..aff5b76f1f11 100644 --- a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js +++ b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js @@ -151,22 +151,6 @@ qx.Class.define("osparc.component.widget.logger.LoggerTable", { return this.__filteredData.length; }, - // overloaded - called whenever the table requests the row count - _loadRowCount : function() { - this.__filteredData = []; - for (let i=0; i Date: Wed, 17 May 2023 11:34:25 +0200 Subject: [PATCH 4/6] LOG_LEVEL_MAP --- .../component/widget/logger/LoggerView.js | 28 ++++++++++++++++--- .../class/osparc/desktop/WorkbenchView.js | 17 ++++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js index 1e77c3591362..45ec16970134 100644 --- a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js +++ b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js @@ -94,6 +94,14 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { error: 2 }, + LOG_LEVEL_MAP: { + 10: "DEBUG", + 20: "INFO", + 30: "WARNING", + 40: "ERROR", + 50: "ERROR" + }, + logLevel2Str: function(logLevel) { const pairFound = Object.entries(this.LOG_LEVELS).find(pair => pair[1] === logLevel); if (pairFound && pairFound.length) { @@ -310,10 +318,6 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.info); }, - infos: function(nodeId, msgs = [""]) { - this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.info); - }, - warn: function(nodeId, msg = "") { this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.warning); }, @@ -322,6 +326,22 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.error); }, + debugs: function(nodeId, msgs = [""]) { + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.debug); + }, + + infos: function(nodeId, msgs = [""]) { + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.info); + }, + + warns: function(nodeId, msgs = [""]) { + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.warning); + }, + + errors: function(nodeId, msgs = [""]) { + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.error); + }, + __addLogs: function(nodeId, msgs = [""], logLevel = 0) { const study = osparc.store.Store.getInstance().getCurrentStudy(); if (study === null) { diff --git a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js index 341bdfdef965..1b11300be557 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js +++ b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js @@ -639,7 +639,22 @@ qx.Class.define("osparc.desktop.WorkbenchView", { } const nodeId = data["node_id"]; const messages = data["messages"]; - this.__loggerView.infos(nodeId, messages); + const logLevelMap = osparc.component.widget.logger.LoggerView.LOG_LEVEL_MAP; + const logLevel = ("log_level" in data) ? logLevelMap[data["log_level"]] : "INFO"; + switch (logLevel) { + case "DEBUG": + this.__loggerView.debugs(nodeId, messages); + break; + case "WARNING": + this.__loggerView.warns(nodeId, messages); + break; + case "ERROR": + this.__loggerView.errors(nodeId, messages); + break; + default: + this.__loggerView.infos(nodeId, messages); + break; + } const nodeLogger = this.__getNodeLogger(nodeId); if (nodeLogger) { nodeLogger.infos(nodeId, messages); From fb0f5dbc8bb6ed915532b78761a0660a662428a0 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 11:35:02 +0200 Subject: [PATCH 5/6] minor --- .../source/class/osparc/component/widget/logger/LoggerView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js index 45ec16970134..0e28c1cafff0 100644 --- a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js +++ b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js @@ -99,7 +99,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { 20: "INFO", 30: "WARNING", 40: "ERROR", - 50: "ERROR" + 50: "ERROR" // CRITICAL }, logLevel2Str: function(logLevel) { From cd0814a97ec856ed2c76a21d7653ab6c49f9f598 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 11:44:14 +0200 Subject: [PATCH 6/6] tpUpperCase --- .../component/widget/logger/LoggerTable.js | 2 +- .../component/widget/logger/LoggerView.js | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js index aff5b76f1f11..4dc106574914 100644 --- a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js +++ b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerTable.js @@ -88,7 +88,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerTable", { let logColor = null; const logLevels = osparc.component.widget.logger.LoggerView.LOG_LEVELS; Object.keys(logLevels).forEach(logLevelKey => { - const logString = logLevelKey; + const logString = logLevelKey.toLowerCase(); const logNumber = logLevels[logLevelKey]; if (logNumber === logLevel) { logColor = colorManager.resolve("logger-"+logString+"-message"); diff --git a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js index 0e28c1cafff0..f562adf5eabd 100644 --- a/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js +++ b/services/static-webserver/client/source/class/osparc/component/widget/logger/LoggerView.js @@ -88,10 +88,10 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { }, LOG_LEVELS: { - debug: -1, - info: 0, - warning: 1, - error: 2 + DEBUG: -1, + INFO: 0, + WARNING: 1, + ERROR: 2 }, LOG_LEVEL_MAP: { @@ -103,9 +103,9 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { }, logLevel2Str: function(logLevel) { - const pairFound = Object.entries(this.LOG_LEVELS).find(pair => pair[1] === logLevel); + const pairFound = Object.entries(this.LOG_LEVELS).find(pair => pair[1] === logLevel.toUpperCase()); if (pairFound && pairFound.length) { - return pairFound[0].toUpperCase(); + return pairFound[0]; } return undefined; } @@ -155,7 +155,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { let logLevelSet = false; Object.keys(this.self().LOG_LEVELS).forEach(logLevelKey => { const logLevel = this.self().LOG_LEVELS[logLevelKey]; - if (logLevelKey === "debug" && !osparc.data.Permissions.getInstance().canDo("study.logger.debug.read")) { + if (logLevelKey === "DEBUG" && !osparc.data.Permissions.getInstance().canDo("study.logger.debug.read")) { return; } const label = qx.lang.String.firstUp(logLevelKey); @@ -311,35 +311,35 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", { }, debug: function(nodeId, msg = "") { - this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.debug); + this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.DEBUG); }, info: function(nodeId, msg = "") { - this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.info); + this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.INFO); }, warn: function(nodeId, msg = "") { - this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.warning); + this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.WARNING); }, error: function(nodeId, msg = "") { - this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.error); + this.__addLogs(nodeId, [msg], this.self().LOG_LEVELS.ERROR); }, debugs: function(nodeId, msgs = [""]) { - this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.debug); + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.DEBUG); }, infos: function(nodeId, msgs = [""]) { - this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.info); + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.INFO); }, warns: function(nodeId, msgs = [""]) { - this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.warning); + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.WARNING); }, errors: function(nodeId, msgs = [""]) { - this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.error); + this.__addLogs(nodeId, msgs, this.self().LOG_LEVELS.ERROR); }, __addLogs: function(nodeId, msgs = [""], logLevel = 0) {