/** * Structured Logging Infrastructure * * Provides consistent, structured logging across the application * Extracted from @revealui/core to break circular dependencies */ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal'; interface LogContext { [key: string]: unknown; userId?: string; requestId?: string; sessionId?: string; traceId?: string; spanId?: string; } interface LogEntry { timestamp: string; level: LogLevel; message: string; context?: LogContext; error?: { name: string; message: string; stack?: string; cause?: unknown; }; metadata?: Record; } interface LoggerConfig { level?: LogLevel; enabled?: boolean; pretty?: boolean; includeTimestamp?: boolean; includeStack?: boolean; destination?: 'console' | 'file' | 'remote'; remoteUrl?: string; onLog?: (entry: LogEntry) => void; } declare class Logger { private config; private context; private extraHandlers; constructor(config?: LoggerConfig); /** * Register an additional log handler (e.g. DB transport). * Called after every log entry, fire-and-forget. Must not throw. */ addLogHandler(handler: (entry: LogEntry) => void): void; /** * Set global context */ setContext(context: LogContext): void; /** * Clear global context */ clearContext(): void; /** * Debug log */ debug(message: string, context?: LogContext): void; /** * Info log */ info(message: string, context?: LogContext): void; /** * Warning log */ warn(message: string, context?: LogContext): void; /** * Error log * * Accepts either an Error object or a LogContext as the second parameter * for backward compatibility with callers that pass structured context. */ error(message: string, errorOrContext?: Error | LogContext, context?: LogContext): void; /** * Fatal log */ fatal(message: string, error?: Error, context?: LogContext): void; /** * Core logging method */ private log; /** * Output log entry */ private output; /** * Output to console */ private outputConsole; /** * Output to file */ private outputFile; /** Circuit breaker state for remote transport */ private remoteFailures; private readonly maxRemoteFailures; /** * Output to remote service (with circuit breaker) */ private outputRemote; /** * Format log entry for pretty printing */ private formatPretty; /** * Create child logger with additional context */ child(context: LogContext): Logger; } /** * Default logger instance */ declare const logger: Logger; /** * Create logger with context */ declare function createLogger(context: LogContext): Logger; /** * Error logger */ declare function logError(error: Error, context?: LogContext): void; /** * Audit logger for security-sensitive operations */ declare function logAudit(action: string, context?: LogContext): void; /** * Database query logger */ declare function logQuery(query: string, duration: number, context?: LogContext): void; export { type LogContext, type LogEntry, type LogLevel, Logger, type LoggerConfig, createLogger, logAudit, logError, logQuery, logger };