From 3832bccc321f0762884303cc8e5e21ed6d5eec84 Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Thu, 14 Jul 2022 13:37:13 +0900 Subject: [PATCH] optimize log output --- app/lib/sqlite3Client.ts | 5 ++++- blitz.config.ts | 3 +++ db/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/lib/sqlite3Client.ts b/app/lib/sqlite3Client.ts index 3280d62..539f1c5 100644 --- a/app/lib/sqlite3Client.ts +++ b/app/lib/sqlite3Client.ts @@ -8,7 +8,10 @@ const databasePath = ? join(process.cwd(), "db", database.replace("file:", "")) : database.replace("file:", "") -const db = new Database(databasePath, { fileMustExist: true }) +const db = new Database(databasePath, { + fileMustExist: true, + verbose: (o) => console.log("\u001b[32mbetter-sqlite3:query\x1b[39m " + o), +}) const getProjectIdByPreparedStatement = db.prepare("SELECT id FROM Project WHERE basePath = ?") const getProjectIdBy = (basePath: string): number | null => { diff --git a/blitz.config.ts b/blitz.config.ts index 7866418..fecb14f 100644 --- a/blitz.config.ts +++ b/blitz.config.ts @@ -1,6 +1,9 @@ import { BlitzConfig, sessionMiddleware, simpleRolesIsAuthorized } from "blitz" const config: BlitzConfig = { + log: { + level: "warn", + }, middleware: [ sessionMiddleware({ cookiePrefix: "co-metub", diff --git a/db/index.ts b/db/index.ts index a63b57b..120b2df 100644 --- a/db/index.ts +++ b/db/index.ts @@ -4,4 +4,4 @@ import { PrismaClient } from "@prisma/client" const EnhancedPrisma = enhancePrisma(PrismaClient) export * from "@prisma/client" -export default new EnhancedPrisma() +export default new EnhancedPrisma({ log: ["query", "warn", "error"] })