errorlog
This commit is contained in:
@@ -48,12 +48,17 @@ function wrapStoreWithTiming(rawStore) {
|
||||
api[method] = async (...args) => {
|
||||
const start = Date.now();
|
||||
try {
|
||||
return await fn(...args);
|
||||
} finally {
|
||||
const duration = Date.now() - start;
|
||||
const result = await fn(...args);
|
||||
console.log(
|
||||
`${chalk.magenta('libstore')} ${namespace}.${method} ${chalk.gray(`(${duration}ms)`)}`
|
||||
`${chalk.magenta('libstore')} ${namespace}.${method} ${chalk.gray(`(${Date.now() - start}ms)`)}`
|
||||
);
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`${chalk.magenta('libstore')} ${namespace}.${method} ${chalk.red('FAILED')} ` +
|
||||
`${chalk.gray(`(${Date.now() - start}ms)`)} ${chalk.red(err.message)}`
|
||||
);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user