chore: 🧹 add .notify to mtb logs

to call the toast, it's useful to propagate non raised errors to the
user simply.
This commit is contained in:
Mel Massadian
2025-09-07 11:55:05 +00:00
committed by Mel Massadian
parent 1e3eb522ac
commit 444e7f816a
+24
View File
@@ -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,
})
},
}
}
}