/** * Removes log files older than the specified number of days. * Throttled per-directory to avoid running on every log line. */ export declare function cleanOldLogs(logDir: string, keepDays: number): void; export declare function getLogFilesByDate(directory: string, datePrefix: string): string[]; export declare function getOption(options: any, key: string, defaultValue: T): T; export declare function ensureDirExists(dirPath: string): void; /** * Sanitize a single path segment so it cannot escape the parent directory * via slashes, drive letters, traversal, or NUL bytes. Falls back to 'logs' * if the input is empty after sanitization. */ export declare function sanitizePathSegment(segment: string): string; export declare function rotateLogs(filePath: string, date: string, fileRotate: boolean): void; export declare function getLogFilePath(appPrefix: string, prefix: string, fileFormat: string): string; export declare function uuidv4(): string; export declare function formatTimestamp(date: Date, timezone: string, use24Hour: boolean): string; /** * Read the last `maxLines` lines of a file without loading the whole thing. * Reads up to `maxBytes` from the tail of the file, splits on '\n', and * returns the last `maxLines`. Returns `{ lines, total }` where `total` is * the count of lines in the bytes we read (so the caller can tell how much * was returned vs. truncated). */ export declare function readLastLines(filePath: string, maxLines: number, maxBytes?: number): { lines: string[]; truncated: boolean; }; /** * Parse a single log file line back into a structured log object. * - JSON-format lines (logger configured with format: 'json') round-trip exactly. * - Plain-format lines (default) recover {level, message, timestamp} via regex; * metadata is empty since plain format doesn't persist it. * - Anything unparseable becomes a CUSTOM-level entry with the raw line as * the message, so the user sees the file content rather than empty rows. */ export declare function parseLogLine(line: string): { level: string; message: string; timestamp: string; metadata: Record; } | null; /** * Coalesce multi-line HTTP watch banners back into one structured record per * request. The watch transport emits 6+ lines per request (separator, * 🔔 New Request Info, 📋 Headers, 📦 Body, ✅ Response Info, 📨 Response * Body, ⏳ completed in Xms, separator). Reading those lines back via * `parseLogLine` yields one log record per line, which renders as banner * soup in the archive viewer. This walker recognizes the banner lines by * `[Request ID: ]` + label and folds them into single records with * `metadata.{method, url, statusCode, duration_ms, headers, body, responseBody, requestId}`. * * Records that don't contain `[Request ID: ...]` pass through unchanged, so * mixed files (or app-log files) still work. Pure separator lines (`====…`) * are dropped as visual noise. */ type ParsedRecord = { level: string; message: string; timestamp: string; metadata: Record; }; export declare function coalesceHttpBanners(records: ParsedRecord[]): ParsedRecord[]; /** * Recursively masks sensitive fields in an object. Skips prototype keys to * avoid prototype-pollution-driven information leaks. */ export declare function maskSensitiveData(data: any, keys: string[]): any; export {};