UNPKG

@hivetechs/hive-ai

Version:

Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API

176 lines 4.71 kB
/** * Structured Logger for Enhanced Error Reporting * * Provides comprehensive logging with structured data, error tracking, * and integration with the health monitoring system. */ export interface LogLevel { DEBUG: 0; INFO: 1; WARN: 2; ERROR: 3; FATAL: 4; } export declare const LOG_LEVELS: LogLevel; export interface LogContext { provider?: string; model?: string; stage?: string; conversationId?: string; requestId?: string; userId?: string; errorType?: string; duration?: number; [key: string]: any; } export interface LogEntry { timestamp: string; level: keyof LogLevel; message: string; context: LogContext; error?: { name: string; message: string; stack?: string; }; } export declare class StructuredLogger { private logs; private maxLogs; protected currentLevel: keyof LogLevel; private enableConsole; constructor(options?: { maxLogs?: number; level?: keyof LogLevel; enableConsole?: boolean; }); /** * Set logging level */ setLevel(level: keyof LogLevel): void; /** * Enable or disable console output */ setConsoleOutput(enabled: boolean): void; /** * Log debug message */ debug(message: string, context?: LogContext): void; /** * Log info message */ info(message: string, context?: LogContext): void; /** * Log warning message */ warn(message: string, context?: LogContext): void; /** * Log error message */ error(message: string, context?: LogContext, error?: Error): void; /** * Log fatal error message */ fatal(message: string, context?: LogContext, error?: Error): void; /** * Log consensus stage start */ stageStart(stage: string, context?: LogContext): void; /** * Log consensus stage completion */ stageComplete(stage: string, duration: number, context?: LogContext): void; /** * Log consensus stage failure */ stageError(stage: string, error: Error, context?: LogContext): void; /** * Log API request start */ apiRequestStart(provider: string, model: string, context?: LogContext): void; /** * Log API request completion */ apiRequestComplete(provider: string, model: string, duration: number, context?: LogContext): void; /** * Log API request error */ apiRequestError(provider: string, model: string, error: Error, context?: LogContext): void; /** * Log circuit breaker event */ circuitBreakerEvent(provider: string, model: string, state: string, context?: LogContext): void; /** * Log fallback event */ fallbackEvent(fromProvider: string, fromModel: string, toProvider: string, toModel: string, context?: LogContext): void; /** * Log health check results */ healthCheck(service: string, status: string, responseTime: number, context?: LogContext): void; /** * Core logging method */ private log; /** * Output log entry to console with formatting */ private outputToConsole; /** * Get recent logs */ getRecentLogs(count?: number): LogEntry[]; /** * Get logs by level */ getLogsByLevel(level: keyof LogLevel, hours?: number): LogEntry[]; /** * Get logs by context */ getLogsByContext(contextFilter: Partial<LogContext>, hours?: number): LogEntry[]; /** * Get error statistics */ getErrorStats(hours?: number): { totalErrors: number; errorsByType: Record<string, number>; errorsByProvider: Record<string, number>; errorsByStage: Record<string, number>; }; /** * Clear logs */ clearLogs(): void; /** * Export logs as JSON */ exportLogs(): string; } /** * Enhanced StructuredLogger with debug patterns */ declare class EnhancedStructuredLogger extends StructuredLogger { /** * Cost calculation debug logging (💰 prefix) */ costDebug(message: string, context?: LogContext): void; /** * Consensus pipeline debug logging (📚 prefix) */ consensusDebug(message: string, context?: LogContext): void; /** * Pipeline enhancement debug logging (🔄 prefix) */ pipelineDebug(message: string, context?: LogContext): void; /** * Toggle debug mode on/off */ enableDebugMode(enabled?: boolean): void; /** * Check if debug mode is active */ isDebugMode(): boolean; } export declare const structuredLogger: EnhancedStructuredLogger; export {}; //# sourceMappingURL=structured-logger.d.ts.map