UNPKG

@memory-bank/mcp

Version:

Memory-enabled Co-Pilot (MCP) server for managing project documentation and context

121 lines 3.21 kB
/** * Unified Logger utility * * Provides a consistent logging interface with structured context support * This is the recommended logging implementation for all application components */ /** * Log levels with clear hierarchy */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; /** * Log level priorities for filtering */ export declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>; /** * Structured log context interface * Provides metadata for log entries */ export interface LogContext { [key: string]: unknown; } /** * Extended log context with common fields */ export interface ExtendedLogContext extends LogContext { /** * Component or module name */ component?: string; /** * Request ID for tracking */ requestId?: string; /** * User ID for tracking */ userId?: string; /** * Branch name for branch-specific logs */ branch?: string; /** * Document path for document-related logs */ documentPath?: string; /** * Error details for error logs */ error?: unknown; /** * Timestamp (auto-populated when not provided) */ timestamp?: string | Date; /** * Additional custom context fields */ [key: string]: unknown; } /** * Unified logger interface * Provides structured logging with context support */ export interface Logger { /** * Log at debug level */ debug(message: string, ...args: unknown[]): void; debug(message: string, context?: LogContext): void; /** * Log at info level */ info(message: string, ...args: unknown[]): void; info(message: string, context?: LogContext): void; /** * Log at warn level */ warn(message: string, ...args: unknown[]): void; warn(message: string, context?: LogContext): void; /** * Log at error level */ error(message: string, ...args: unknown[]): void; error(message: string, context?: LogContext): void; /** * Generic log method with explicit level */ log(level: LogLevel, message: string, ...args: unknown[]): void; log(level: LogLevel, message: string, context?: LogContext): void; /** * Set minimum log level */ setLevel(level: LogLevel): void; /** * Get current log level */ getLevel(): LogLevel; /** * Create a new logger with additional context * All logs from the derived logger will include this context */ withContext(context: LogContext): Logger; } /** * Create a console logger * @param level Minimum log level to display * @returns Logger instance */ export declare function createConsoleLogger(level?: LogLevel, initialDefaultContext?: LogContext): Logger; /** * Default logger instance configured with warn level * Use this for direct imports across the application * For component-specific logging, create a contextualized logger with withContext * * Example: * ``` * const componentLogger = logger.withContext({ component: 'UserRepository' }); * componentLogger.info('User data retrieved', { userId: 123 }); * ``` */ export declare const logger: Logger; //# sourceMappingURL=logger.d.ts.map