/** * Structured logging for migration operations. * * Provides audit trail and debugging support for all migration phases. * Logs are written in JSONL format for easy parsing and appending. * * @task T4727 * @epic T4454 */ /** Log entry severity level */ export type LogLevel = 'info' | 'warn' | 'error' | 'debug'; /** Single migration log entry */ export interface MigrationLogEntry { /** ISO 8601 timestamp */ timestamp: string; /** Log level */ level: LogLevel; /** Migration phase (init, backup, import, verify, complete, etc.) */ phase: string; /** Specific operation within phase */ operation: string; /** Human-readable message */ message: string; /** Duration since migration start in milliseconds */ durationMs: number; /** Additional structured data */ data?: Record; } /** Migration logger configuration */ export interface MigrationLoggerConfig { /** Maximum number of log files to retain */ maxLogFiles?: number; /** Minimum log level to record */ minLevel?: LogLevel; /** Enable console output in addition to file logging */ consoleOutput?: boolean; } /** Structured logger for migration operations */ export declare class MigrationLogger { private logPath; private entries; private startTime; private cleoDir; private config; /** * Create a new migration logger. * @param cleoDir - Path to .cleo directory * @param config - Optional configuration */ constructor(cleoDir: string, config?: MigrationLoggerConfig); /** * Get numeric priority for log level comparison. */ private getLevelPriority; /** * Check if a log level should be recorded. */ private shouldLog; /** * Write a log entry. */ private log; /** * Log an info-level message. */ info(phase: string, operation: string, message: string, data?: Record): void; /** * Log a warning-level message. */ warn(phase: string, operation: string, message: string, data?: Record): void; /** * Log an error-level message. */ error(phase: string, operation: string, message: string, data?: Record): void; /** * Log a debug-level message. */ debug(phase: string, operation: string, message: string, data?: Record): void; /** * Log file operation with size information. */ logFileOperation(phase: string, operation: 'read' | 'write' | 'backup' | 'rename' | 'delete', sourcePath: string, targetPath?: string, additionalData?: Record): void; /** * Log validation result. */ logValidation(phase: string, target: string, valid: boolean, details?: Record, errors?: string[]): void; /** * Log import progress. */ logImportProgress(phase: string, entityType: string, imported: number, total: number, additionalData?: Record): void; /** * Log phase start. */ phaseStart(phase: string, data?: Record): void; /** * Log phase completion. */ phaseComplete(phase: string, data?: Record): void; /** * Log phase failure. */ phaseFailed(phase: string, error: Error | string, data?: Record): void; /** * Clean up old log files, keeping only the most recent ones. */ private cleanupOldLogs; /** * Get the absolute path to the log file. */ getLogPath(): string; /** * Get the path to the log file relative to cleoDir. */ getRelativeLogPath(): string; /** * Get all logged entries. */ getEntries(): MigrationLogEntry[]; /** * Get entries filtered by level. */ getEntriesByLevel(level: LogLevel): MigrationLogEntry[]; /** * Get entries for a specific phase. */ getEntriesByPhase(phase: string): MigrationLogEntry[]; /** * Get the total duration of the migration so far. */ getDurationMs(): number; /** * Get summary statistics for the migration. */ getSummary(): { totalEntries: number; durationMs: number; errors: number; warnings: number; info: number; debug: number; phases: string[]; }; } /** * Create a migration logger for the given cleo directory. * Convenience function for functional programming style. */ export declare function createMigrationLogger(cleoDir: string, config?: MigrationLoggerConfig): MigrationLogger; /** * Read and parse a migration log file. */ export declare function readMigrationLog(logPath: string): MigrationLogEntry[]; /** * Check if a log file exists and is readable. */ export declare function logFileExists(logPath: string): boolean; /** * Get the most recent migration log file for a cleo directory. */ export declare function getLatestMigrationLog(cleoDir: string): string | null; //# sourceMappingURL=logger.d.ts.map