Improve Transactions handling #28
@ -11,7 +11,10 @@ const app = createApp(App)
|
||||
app.use(router)
|
||||
|
||||
const pinia = createPinia()
|
||||
pinia.use(PiniaLogger())
|
||||
pinia.use(PiniaLogger({
|
||||
expanded: false,
|
||||
showDuration: true
|
||||
}))
|
||||
app.use(pinia)
|
||||
app.mount('#app')
|
||||
|
||||
|
@ -11,9 +11,8 @@ const formatTime = (date = new Date()) => {
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
const seconds = date.getSeconds().toString().padStart(2, '0');
|
||||
const milliseconds = date.getMilliseconds().toString();
|
||||
|
||||
return `${hours}:${minutes}:${seconds}:${milliseconds}`;
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
};
|
||||
|
||||
export interface PiniaLoggerOptions {
|
||||
@ -52,7 +51,7 @@ export const PiniaLogger = (config = defaultOptions) => (ctx: PiniaPluginContext
|
||||
const duration = endTime - startTime + 'ms';
|
||||
const nextState = cloneDeep(ctx.store.$state);
|
||||
const storeName = action.store.$id;
|
||||
const title = `action 🍍 ${options.showStoreName ? `[${storeName}] ` : ''}${action.name} ${isError ? `failed after ${duration} ` : ''}@ ${formatTime()}`;
|
||||
const title = `${formatTime()} action 🍍 ${options.showStoreName ? `[${storeName}] ` : ''}${action.name} ${isError ? `failed after ` : ''}in ${duration}`;
|
||||
|
||||
console[options.expanded ? 'group' : 'groupCollapsed'](`%c${title}`, `font-weight: bold; ${isError ? 'color: #ed4981;' : ''}`);
|
||||
console.log('%cprev state', 'font-weight: bold; color: grey;', prevState);
|
||||
|
Loading…
x
Reference in New Issue
Block a user