/** * Smart Logs Tool - System Log Aggregation and Analysis * * Provides intelligent log analysis with: * - Multi-source log aggregation * - Pattern filtering and error detection * - Log level analysis * - Token-optimized output */ import { CacheEngine } from '../../core/cache-engine.js'; interface SmartLogsOptions { /** * Log sources to aggregate (file paths or system logs) */ sources?: string[]; /** * Filter by log level */ level?: 'error' | 'warn' | 'info' | 'debug' | 'all'; /** * Filter by pattern (regex) */ pattern?: string; /** * Number of lines to tail */ tail?: number; /** * Follow mode (watch for new entries) */ follow?: boolean; /** * Time range filter (e.g., '1h', '24h', '7d') */ since?: string; /** * Project root directory */ projectRoot?: string; /** * Maximum cache age in seconds (default: 300 = 5 minutes for logs) */ maxCacheAge?: number; } interface SmartLogsOutput { /** * Summary */ summary: { success: boolean; totalEntries: number; errorCount: number; warnCount: number; timeRange: string; duration: number; fromCache: boolean; }; /** * Log entries (filtered and categorized) */ entries: Array<{ timestamp: string; level: string; source: string; message: string; }>; /** * Statistics */ stats: { byLevel: Record; bySource: Record; }; /** * Detected patterns (common error messages) */ patterns: Array<{ pattern: string; count: number; severity: 'critical' | 'high' | 'medium' | 'low'; }>; /** * Analysis insights */ insights: Array<{ type: 'error' | 'warning' | 'performance'; message: string; impact: 'high' | 'medium' | 'low'; }>; /** * Token reduction metrics */ metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartLogs { private cache; private cacheNamespace; private projectRoot; constructor(cache: CacheEngine, projectRoot?: string); /** * Aggregate and analyze logs */ run(options?: SmartLogsOptions): Promise; /** * Aggregate logs from multiple sources */ private aggregateLogs; /** * Get default log sources based on OS */ private getDefaultLogSources; /** * Read logs from a single source */ private readLogSource; /** * Read logs from a file */ private readFileLog; /** * Read system logs */ private readSystemLogs; /** * Parse a log line */ private parseLogLine; /** * Parse system log entry */ private parseSystemLogEntry; /** * Detect log level from message */ private detectLogLevel; /** * Map system log level to our levels */ private mapSystemLogLevel; /** * Parse time range string */ private parseTimeRange; /** * Calculate statistics */ private calculateStats; /** * Detect common patterns */ private detectPatterns; /** * Generate insights */ private generateInsights; /** * Generate cache key */ private generateCacheKey; /** * Get cached result */ private getCachedResult; /** * Cache result */ private cacheResult; /** * Transform to smart output */ private transformOutput; /** * Format cached output */ private formatCachedOutput; /** * Estimate original output size */ private estimateOriginalOutputSize; /** * Estimate compact output size */ private estimateCompactSize; /** * Close cache connection */ close(): void; } /** * Factory function for dependency injection */ export declare function getSmartLogs(cache: CacheEngine, projectRoot?: string): SmartLogs; /** * CLI-friendly function for running smart logs */ export declare function runSmartLogs(options?: SmartLogsOptions): Promise; export declare const SMART_LOGS_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { sources: { type: string; items: { type: string; }; description: string; }; level: { type: string; enum: string[]; description: string; default: string; }; pattern: { type: string; description: string; }; tail: { type: string; description: string; default: number; }; follow: { type: string; description: string; default: boolean; }; since: { type: string; description: string; }; projectRoot: { type: string; description: string; }; maxCacheAge: { type: string; description: string; default: number; }; }; }; }; export {}; //# sourceMappingURL=smart-logs.d.ts.map