c
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import chalk from 'chalk';
|
||||
import LibDashStore from 'libdashstore';
|
||||
import { MssqlProvider } from 'libdashstore/providers/mssql';
|
||||
import { BetterSqlite3Provider } from 'libdashstore/providers/better-sqlite3';
|
||||
import env from '../config/env.js';
|
||||
import { createLogger, chalk } from '../util/logger.js';
|
||||
|
||||
const storeLog = createLogger('libstore');
|
||||
|
||||
let provider;
|
||||
let store;
|
||||
@@ -65,13 +67,11 @@ function wrapStoreWithTiming(rawStore) {
|
||||
const start = Date.now();
|
||||
try {
|
||||
const result = await fn(...args);
|
||||
console.log(
|
||||
`${chalk.magenta('libstore')} ${namespace}.${method} ${chalk.gray(`(${Date.now() - start}ms)`)}`
|
||||
);
|
||||
storeLog.debug(`${namespace}.${method} ${chalk.gray(`(${Date.now() - start}ms)`)}`);
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`${chalk.magenta('libstore')} ${namespace}.${method} ${chalk.red('FAILED')} ` +
|
||||
storeLog.error(
|
||||
`${namespace}.${method} ${chalk.red('FAILED')} ` +
|
||||
`${chalk.gray(`(${Date.now() - start}ms)`)} ${chalk.red(err.message)}`
|
||||
);
|
||||
throw err;
|
||||
@@ -90,7 +90,7 @@ function wrapStoreWithTiming(rawStore) {
|
||||
return await fn(...args);
|
||||
} finally {
|
||||
const duration = Date.now() - start;
|
||||
console.log(`${chalk.magenta('libstore')} ${method} ${chalk.gray(`(${duration}ms)`)}`);
|
||||
storeLog.info(`${method} ${chalk.gray(`(${duration}ms)`)}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user