Skip to content

Commit

Permalink
Improve logging and check if dev or prod
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Apr 29, 2024
1 parent 9b5853c commit a45b9f1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export let container: HTMLElement;
export let containers: HTMLElement[] = [];
export let containerIndex: number = 0;

export const dev = import.meta.env.DEV;

export function resetContainers() {
containers = [];
containers.push(container);
Expand Down Expand Up @@ -71,6 +73,41 @@ interface ShortcutIcon {
WFWorkflowIconGlyphNumber: number
}

export const Log = {
info(...message: string[]) {
Log.log('info', ...message);
},
error(...message: string[]) {
Log.log('err', ...message);
},
warn(...message: string[]) {
Log.log('warn', ...message);
},
debug(...message: string[]) {
Log.log('debug', ...message);
},
log(type: string, ...message: string[]) {
const prefix = '[preview-shortcut]';
switch (type) {
case 'info':
console.info(prefix, ...message);
break;
case 'err':
console.error(prefix, ...message);
break;
case 'warn':
console.warn(prefix, ...message);
break;
case 'debug':
if (!dev) {
return;
}
console.log(prefix, ...message);
break;
}
}
};

export class ShortcutPreview {
selector: string
name: string
Expand Down

0 comments on commit a45b9f1

Please sign in to comment.