/** * Persistent circular buffer for log entries with periodic cleanup. * * Maintains a large history of logs without memory leaks by using * a circular buffer with periodic cleanup. Supports pagination, * search, and efficient querying. * * @module components/devenv/terminal/parsing/PersistentLogBuffer */ import type { IParsedLogEntry } from './LogParser.types'; /** * Configuration for the persistent log buffer. */ export interface IPersistentLogBufferConfig { /** Maximum number of entries to store (default: 50,000) */ maxSize: number; /** Soft limit that triggers cleanup (default: 40,000) */ softLimit: number; /** Number of entries to remove per cleanup batch (default: 5,000) */ cleanupBatch: number; /** Cleanup interval in milliseconds (default: 30,000 ms = 30s) */ cleanupInterval: number; } /** * Buffer statistics for monitoring. */ export interface IBufferStats { /** Current number of entries */ size: number; /** Maximum configured size */ maxSize: number; /** Usage ratio (0-1) */ usage: number; /** First line number in buffer */ firstLine: number | undefined; /** Last line number in buffer */ lastLine: number | undefined; /** Memory usage estimate (bytes) */ memoryUsage: number; } /** * Search options for querying the buffer. */ export interface ISearchOptions { /** Start from line number */ fromLine?: number; /** Maximum results to return */ limit?: number; /** Case insensitive search */ caseInsensitive?: boolean; } /** * Persistent circular buffer for log entries. * * Features: * - Circular buffer with automatic cleanup * - Pagination support for large datasets * - Search by pattern * - Memory-efficient storage * - Periodic cleanup to prevent memory leaks * * @example * ```ts * const buffer = new PersistentLogBuffer({ maxSize: 50000 }); * buffer.append(entries); * const page1 = buffer.getEntries({ offset: 0, limit: 100 }); * const results = buffer.search(/error/i); * ``` */ export declare class PersistentLogBuffer { /** Internal storage for entries */ private buffer; /** Buffer configuration */ private config; /** Cleanup timer reference */ private cleanupTimer?; /** Cleanup scheduled flag */ private cleanupScheduled; /** * Create a new persistent log buffer. * * @param config - Buffer configuration */ constructor(config?: Partial); /** * Append entries to the buffer. * * If the buffer exceeds the soft limit, schedules a cleanup. * * @param entries - Entries to append */ append(entries: IParsedLogEntry[]): void; /** * Prepend entries to the buffer (for loading historical logs). * * @param entries - Entries to prepend */ prepend(entries: IParsedLogEntry[]): void; /** * Get entries from the buffer with pagination. * * @param options - Query options * @returns Array of entries */ getEntries(options?: { offset?: number; limit?: number; fromLine?: number; toLine?: number; }): IParsedLogEntry[]; /** * Get all entries in the buffer. * * @returns All entries */ getAllEntries(): IParsedLogEntry[]; /** * Get the total number of entries. * * @returns Entry count */ getSize(): number; /** * Search entries by pattern. * * @param pattern - RegExp pattern or string to search * @param options - Search options * @returns Matching entries */ search(pattern: RegExp | string, options?: ISearchOptions): IParsedLogEntry[]; /** * Find entries by line number. * * @param lineNumbers - Array of line numbers to find * @returns Matching entries */ findByLineNumbers(lineNumbers: number[]): IParsedLogEntry[]; /** * Get entries filtered by log level. * * @param level - Log level to filter by * @returns Filtered entries */ getByLevel(level: string): IParsedLogEntry[]; /** * Clear all entries from the buffer. */ clear(): void; /** * Get buffer statistics. * * @returns Buffer statistics */ getStats(): IBufferStats; /** * Schedule a cleanup operation. */ private scheduleCleanup; /** * Perform cleanup of old entries. * * Removes the oldest entries to keep the buffer within limits. */ private cleanup; /** * Start the periodic cleanup timer. */ private startCleanupTimer; /** * Stop the cleanup timer and clear resources. */ destroy(): void; } /** * Create a new persistent log buffer with default configuration. * * @param config - Optional configuration overrides * @returns New buffer instance */ export declare function createPersistentLogBuffer(config?: Partial): PersistentLogBuffer; //# sourceMappingURL=PersistentLogBuffer.d.ts.map