mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-10 17:14:20 +01:00
19 lines
489 B
TypeScript
19 lines
489 B
TypeScript
import { Stickynotes } from '@soapbox/stickynotes';
|
|
import { Logger } from 'kysely';
|
|
|
|
/** Log the SQL for queries. */
|
|
export const KyselyLogger: Logger = (event) => {
|
|
if (event.level === 'query') {
|
|
const console = new Stickynotes('ditto:sql');
|
|
|
|
const { query, queryDurationMillis } = event;
|
|
const { sql, parameters } = query;
|
|
|
|
console.debug(
|
|
sql,
|
|
JSON.stringify(parameters),
|
|
`\x1b[90m(${(queryDurationMillis / 1000).toFixed(2)}s)\x1b[0m`,
|
|
);
|
|
}
|
|
};
|