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:
@@ -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,
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user