From dc655b9ed002f89ae1b6cd874bbe68193018f4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 21 Dec 2023 18:43:17 +0100 Subject: [PATCH] main: Override global logError() function logError() prints an exception with an optional prefix, and is used fairly commonly through-out the code base. The problem is that by being defined in gjs, it uses "Gjs" as the GLib log domain, not our own as expected. Address this by adding a small override that implements the function with console.error(). Part-of: --- js/ui/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/ui/main.js b/js/ui/main.js index ad6d3d611..3781c9607 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -143,6 +143,16 @@ function _sessionUpdated() { /** @returns {void} */ export async function start() { globalThis.log = console.log; + globalThis.logError = function (err, msg) { + const args = [err]; + try { + // toString() can throw + if (msg) + args.unshift(`${msg}:`); + } catch (e) {} + + console.error(...args); + }; // Chain up async errors reported from C global.connect('notify-error', (global, msg, detail) => {