feat(log): add pino logging support

This commit is contained in:
cfngc4594 2025-05-04 21:35:44 +08:00
parent 4b4dcb1ff5
commit 613dd5ef17
2 changed files with 22 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import createNextIntlPlugin from 'next-intl/plugin';
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
serverExternalPackages: ["dockerode"], serverExternalPackages: ["dockerode", "pino", "pino-pretty"],
}; };
const withNextIntl = createNextIntlPlugin(); const withNextIntl = createNextIntlPlugin();

21
src/lib/logger.ts Normal file
View File

@ -0,0 +1,21 @@
import pino from "pino";
const logger =
process.env["NODE_ENV"] === "production"
? // JSON in production
pino({ level: "info" })
: // Pretty print in development
pino({
level: "debug",
transport: {
target: "pino-pretty",
options: {
levelFirst: true,
colorize: true,
ignore: "hostname,pid",
translateTime: "yyyy-mm-dd HH:MM:ss",
},
},
});
export { logger };