/** * Advanced structured logger with color support, file output, and context-aware logging. * * This logger provides comprehensive logging capabilities with the following features: * - ANSI color-coded console output with different colors for each log level * - Structured context information including PID, server name, trace ID, span ID * - File output with plain text formatting (no colors) for log analysis * - Development mode with automatic log file creation and clearing * - Context-aware logging with module, traceId, and spanId support * - Error formatting with stack trace truncation to prevent overly verbose logs * - MCP server-specific logging with serverName context * - Log rotation with date-based file naming and automatic cleanup * - Caller location information (file name and line number) * * The logger supports four log levels: debug, info, warn, and error, with configurable * minimum log level threshold. * * @example * ```typescript * // Basic usage * logger.info('Server started', { port: 7788 }); * * // With context * logger.error('Connection failed', { error: err.message, serverName: 'my-server' }); * * // Development mode * logger.enableDevLog(); * ``` */ import type { LogLevel } from '../../../shared/types/common.types.js'; import type { LogContext } from './log-context.js'; import { DevLogger } from './dev-logger.js'; export declare class Logger { private level; private useStderr; private useColor; private showCaller; private devLogger; constructor(level?: LogLevel); /** * Enable or disable caller information in logs. * When enabled, logs will show the file name and line number where the log was called. * * @param show - Whether to show caller information * @example * ```typescript * logger.setShowCaller(false); // Disable caller info * ``` */ setShowCaller(show: boolean): void; /** * Enables development logging mode with file output and enhanced debugging. * * @param rotatorConfig - Optional custom rotation configuration (default: 7 days retention) * @example * ```typescript * const logger = new Logger(); * logger.enableDevLog(); // Logs will be written to logs/dev-server.2026-02-27.log * * // With custom retention period * logger.enableDevLog({ rotationAge: '14d' }); * ``` */ enableDevLog(rotatorConfig?: Parameters[0]): void; setUseStderr(use: boolean): void; /** * Enable or disable ANSI color output. * When disabled, logs will be plain text without color codes. * * @param use - Whether to use color in output * @example * ```typescript * logger.setUseColor(false); // Plain text output for files * ``` */ setUseColor(use: boolean): void; /** * Check if a message should be logged at the current level. * @internal Public for testing only */ shouldLog(messageLevel: LogLevel): boolean; /** * Generic logging method to eliminate code duplication. */ private log; /** * Logs a debug message with optional context and additional arguments. * * @param message - The primary log message * @param args - Additional arguments to include in the log * * @example * ```typescript * // Basic debug message * logger.debug('Processing request'); * * // With context * logger.debug('Tool called', { module: 'Gateway', traceId: 'abc123' }, toolName, args); * ``` */ debug(message: string, ...args: unknown[]): void; /** * Logs an informational message with optional context and additional arguments. * * @param message - The primary log message * @param args - Additional arguments to include in the log * * @example * ```typescript * // Basic info message * logger.info('Server started successfully'); * * // With context and additional data * logger.info('Request processed', { module: 'API' }, { duration: 150, statusCode: 200 }); * ``` */ info(message: string, ...args: unknown[]): void; /** * Logs a warning message with optional context and additional arguments. * * @param message - The primary log message * @param args - Additional arguments to include in the log * * @example * ```typescript * // Basic warning message * logger.warn('Deprecated API usage detected'); * * // With context and error details * logger.warn('Connection timeout', { module: 'Network' }, { server: 'api.example.com', timeout: 5000 }); * ``` */ warn(message: string, ...args: unknown[]): void; /** * Logs an error message with optional context and additional arguments. * * @param message - The primary log message * @param args - Additional arguments to include in the log * * @example * ```typescript * // Basic error message * logger.error('Database connection failed'); * * // With error object and context * logger.error('Request processing failed', { module: 'API' }, error, { requestId: '123' }); * ``` */ error(message: string, ...args: unknown[]): void; private extractOptionsAndArgs; setLevel(level: LogLevel): void; /** * Method specifically for MCP Server logging. * Handles multi-line messages by splitting them into individual log entries. */ serverLog(level: LogLevel, serverName: string, message: string, context?: Omit): void; /** * Internal helper to log a single line for serverLog. * Contains the core logging logic originally in serverLog. */ private logSingleServerLine; /** * Internal accessor for testing and legacy compatibility. * @internal */ get logFileStream(): unknown; /** * Internal accessor for testing and legacy compatibility. * @internal */ get devLogRotator(): unknown; /** * Internal method for testing and legacy compatibility. * @internal */ createColoredLogMessage(level: LogLevel, message: string, context?: LogContext): string; /** * Internal method for testing and legacy compatibility. * @internal */ createLogMessage(level: LogLevel, message: string, context?: LogContext): string; /** * Internal method for testing and legacy compatibility. * @internal */ formatError(error: unknown): string; /** * Internal method for testing and legacy compatibility. * @internal */ formatTimestamp(date: Date): string; /** * Internal method for testing and legacy compatibility. * @internal */ formatLogLevel(level: LogLevel): string; /** * Internal method for testing and legacy compatibility. * @internal */ formatPid(pid: number): string; } //# sourceMappingURL=logger.d.ts.map