Browse Source

fix: 修复在 Turbopack 环境下的 Pino 日志实例创建逻辑

sususu98 3 months ago
parent
commit
f280e155d8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/lib/logger.ts

+ 5 - 1
src/lib/logger.ts

@@ -30,10 +30,14 @@ function getInitialLogLevel(): LogLevel {
 
 /**
  * 创建 Pino 日志实例
+ * pino-pretty 在 Next.js 15 + Turbopack 下有兼容性问题,暂时禁用
+ * 在 Turbopack 环境下使用默认格式化器(不启用 pino-pretty)
  */
+const enablePrettyTransport = isDevelopment() && !process.env.TURBOPACK;
+
 const pinoInstance = pino({
   level: getInitialLogLevel(),
-  transport: isDevelopment()
+  transport: enablePrettyTransport
     ? {
         target: "pino-pretty",
         options: {