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, + }) + }, + } } }