feat: 增加结构化请求日志
- src/common/logging: 新增 Pino 结构化日志服务和 HTTP 请求日志拦截器 - src/main.ts: 全局接入请求日志并保留响应 envelope - package.json: 增加 pino 运行时依赖
This commit is contained in:
+5
-1
@@ -4,6 +4,7 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
import { ApiEnvelopeInterceptor } from './common/http/api-envelope.interceptor';
|
||||
import { AllExceptionsFilter } from './common/http/all-exceptions.filter';
|
||||
import { HttpRequestLoggingInterceptor } from './common/logging/http-request-logging.interceptor';
|
||||
import { EnvConfig } from './config/env.schema';
|
||||
|
||||
async function bootstrap(): Promise<void> {
|
||||
@@ -19,7 +20,10 @@ async function bootstrap(): Promise<void> {
|
||||
credentials: true,
|
||||
});
|
||||
app.useGlobalFilters(new AllExceptionsFilter());
|
||||
app.useGlobalInterceptors(new ApiEnvelopeInterceptor());
|
||||
app.useGlobalInterceptors(
|
||||
app.get(HttpRequestLoggingInterceptor),
|
||||
new ApiEnvelopeInterceptor(),
|
||||
);
|
||||
|
||||
const swaggerConfig = new DocumentBuilder()
|
||||
.setTitle('运维平台 API')
|
||||
|
||||
Reference in New Issue
Block a user