From 444e7f816a7a2bba757ce33bfff074d92fb53f90 Mon Sep 17 00:00:00 2001 From: Mel Massadian Date: Mon, 4 Aug 2025 21:03:17 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A7=B9=20add=20.notify=20to=20mt?= =?UTF-8?q?b=20logs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to call the toast, it's useful to propagate non raised errors to the user simply. --- web/comfy_shared.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/web/comfy_shared.js b/web/comfy_shared.js index 0b2582f..7cc2cd9 100644 --- a/web/comfy_shared.js +++ b/web/comfy_shared.js @@ -118,6 +118,20 @@ export class LocalStorageManager { // - log utilities +const consoleMethodToSeverity = (method) => { + switch (method) { + case 'log': { + return 'info' + } + case 'error' | 'warn': { + return method + } + default: { + return 'secondary' + } + } +} + function createLogger(emoji, color, consoleMethod = 'log') { return (message, ...args) => { if (window.MTB?.DEBUG) { @@ -127,6 +141,16 @@ function createLogger(emoji, color, consoleMethod = 'log') { ...args, ) } + return { + notify: (timeout = 3000) => { + app.extensionManager.toast.add({ + severity: consoleMethodToSeverity(consoleMethod), + summary: 'MTB', + detail: `${emoji} ${message}`, + life: timeout, + }) + }, + } } }