fix(SEC-API-28): Replace MCP console.error with NestJS Logger
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Replace all console.error calls in MCP services with NestJS Logger instances for consistent structured logging in production. - mcp-hub.service.ts: Add Logger instance, replace console.error in onModuleDestroy cleanup - stdio-transport.ts: Add Logger instance, replace console.error for stderr output (as warn) and JSON parse failures (as error) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable, OnModuleDestroy } from "@nestjs/common";
|
||||
import { Injectable, Logger, OnModuleDestroy } from "@nestjs/common";
|
||||
import { StdioTransport } from "./stdio-transport";
|
||||
import { ToolRegistryService } from "./tool-registry.service";
|
||||
import type { McpServer, McpServerConfig, McpRequest, McpResponse } from "./interfaces";
|
||||
@@ -16,6 +16,7 @@ interface McpServerWithTransport extends McpServer {
|
||||
*/
|
||||
@Injectable()
|
||||
export class McpHubService implements OnModuleDestroy {
|
||||
private readonly logger = new Logger(McpHubService.name);
|
||||
private servers = new Map<string, McpServerWithTransport>();
|
||||
|
||||
constructor(private readonly toolRegistry: ToolRegistryService) {}
|
||||
@@ -161,7 +162,7 @@ export class McpHubService implements OnModuleDestroy {
|
||||
async onModuleDestroy(): Promise<void> {
|
||||
const stopPromises = Array.from(this.servers.keys()).map((serverId) =>
|
||||
this.stopServer(serverId).catch((error: unknown) => {
|
||||
console.error(`Failed to stop server ${serverId}:`, error);
|
||||
this.logger.error(`Failed to stop server ${serverId}:`, error);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user