From 05c59937e9cbdc62015741d1eb56656eb8d0dbd6 Mon Sep 17 00:00:00 2001 From: monoid Date: Thu, 7 Nov 2024 05:18:01 +0900 Subject: [PATCH] feat: kysely detail logs on error --- packages/server/src/db/kysely.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/server/src/db/kysely.ts b/packages/server/src/db/kysely.ts index 6307668..75ca907 100644 --- a/packages/server/src/db/kysely.ts +++ b/packages/server/src/db/kysely.ts @@ -22,7 +22,17 @@ export function getKysely() { kysely = new Kysely({ dialect: createSqliteDialect(), // plugins: [new ParseJSONResultsPlugin()], + log: (event) => { + if (event.level === "error") { + console.error("Query failed : ", { + durationMs: event.queryDurationMillis, + error: event.error, + sql: event.query.sql, + params: event.query.parameters, + }); + } + } }); } return kysely; -} \ No newline at end of file +}