This commit is contained in:
seb
2026-10-08 03:43:28 +02:00
parent c543c76a21
commit 717f4754d4
9 changed files with 787 additions and 24 deletions

View File

@@ -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)`)}`);
}
};
}