From 38864e67655e5e8a4e30fcea29f7f91c2a690c65 Mon Sep 17 00:00:00 2001 From: pmario Date: Thu, 15 Dec 2022 16:48:43 +0100 Subject: [PATCH] add console-error to the Logger class --- core/modules/utils/logger.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/logger.js b/core/modules/utils/logger.js index 1bee04646..93b054181 100644 --- a/core/modules/utils/logger.js +++ b/core/modules/utils/logger.js @@ -52,7 +52,19 @@ Logger.prototype.log = function(/* args */) { logMessage[logMessage.length-1] += $tw.utils.terminalColour(); return Function.apply.call(console.log, console, logMessage); } - } + } +}; + +/* +Log an error message to console.error so it also gets a red colour in browsers +*/ +Logger.prototype.error = function(/* args */) { + var self = this; + if(console !== undefined && console.error !== undefined) { + var logMessage = [$tw.utils.terminalColour(this.colour) + this.componentName + ":"].concat(Array.prototype.slice.call(arguments,0)); + logMessage[logMessage.length-1] += $tw.utils.terminalColour(); + return Function.apply.call(console.error, console, logMessage); + } }; /*