chore: add granular logging to the logger (#16734)

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update turbo.json

* Update trpc-provider.tsx

* Update logger.ts

* update prisma index

* Update trpc.ts

* Update trpc-provider.tsx

* Update trpc.ts

* Update .env.example

* Update logger.ts
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2024-09-20 09:06:37 +00:00
1 parent e0922c5ee0
commit c4a1382982
7 files changed
+48 -7

No files matched your search

+20 -1
View File
@@ -15,7 +15,26 @@ const globalForPrisma = global as unknown as {
prismaWithClientExtensions: PrismaClientWithExtensions;
};
if (!!process.env.NEXT_PUBLIC_DEBUG) prismaOptions.log = ["query", "error", "warn"];
const loggerLevel = parseInt(process.env.NEXT_PUBLIC_LOGGER_LEVEL ?? "", 10);
if (!isNaN(loggerLevel)) {
switch (loggerLevel) {
case 5:
case 6:
prismaOptions.log = ["error"];
break;
case 4:
prismaOptions.log = ["warn", "error"];
break;
case 3:
prismaOptions.log = ["info", "error", "warn"];
break;
default:
// For values 0, 1, 2 (or anything else below 3)
prismaOptions.log = ["query", "info", "error", "warn"];
break;
}
}
// Prevents flooding with idle connections
const prismaWithoutClientExtensions =