Kaynağa Gözat

日志优化

hl 1 hafta önce
ebeveyn
işleme
9148737b3a
1 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 3 2
      client.js

+ 3 - 2
client.js

@@ -59,11 +59,12 @@ process.on('uncaughtException', (err) => {
 
     // 可选: 记录其他上下文信息
     // 例如,您可以添加时间戳、请求信息等
-    logger.info('捕获到未处理的异常:', {
+    // 记录异常的详细信息
+    logger.info('捕获到未处理的异常:', JSON.stringify({
         timestamp: new Date(),
         error: err.message,
         stack: err.stack
-    });
+    }, null, 2));  // 使用 JSON.stringify 格式化输出
 
     // 在这里执行清理工作
     process.exit(1); // 非零退出码表示异常退出