Index: gc_core/js/helpers.js ================================================================== --- gc_core/js/helpers.js +++ gc_core/js/helpers.js @@ -1,23 +1,22 @@ // HELPERS "use strict"; -let funcOutput = null; - const helpers = { // In Firefox, there is no console.log in PromiseWorker, but there is worker.log. // In Thunderbird, you can’t access to console directly. So it’s required to pass a log function. + _funcOutput: null, setLogOutput: function (func) { - funcOutput = func; + this._funcOutput = func; }, echo: function (obj) { - if (funcOutput !== null) { - funcOutput(obj); + if (this._funcOutput !== null) { + this._funcOutput(obj); } else { console.log(obj); } return true; }, @@ -25,12 +24,12 @@ logerror: function (e, bStack=false) { let sMsg = "\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message; if (bStack) { sMsg += "\n--- Stack ---\n" + e.stack; } - if (funcOutput !== null) { - funcOutput(sMsg); + if (this._funcOutput !== null) { + this._funcOutput(sMsg); } else { console.error(sMsg); } },