/** * Structured logging interfaces and event definitions. * * Provides standardized event names and context fields for log aggregation * and observability tooling. * * @see Issue #16: Add structured log enrichment with context fields */ /** * Standardized event names for log filtering and aggregation. * * Format: `{domain}:{operation}:{status}` * - domain: memory, task, session, handler * - operation: load, save, search, capture, sync * - status: start, complete, error, timeout */ export declare const LogEvents: { readonly MEMORY_LOAD_START: "memory:load:start"; readonly MEMORY_LOAD_COMPLETE: "memory:load:complete"; readonly MEMORY_LOAD_ERROR: "memory:load:error"; readonly MEMORY_LOAD_TIMEOUT: "memory:load:timeout"; readonly MEMORY_SAVE_START: "memory:save:start"; readonly MEMORY_SAVE_COMPLETE: "memory:save:complete"; readonly MEMORY_SAVE_ERROR: "memory:save:error"; readonly MEMORY_SEARCH_START: "memory:search:start"; readonly MEMORY_SEARCH_COMPLETE: "memory:search:complete"; readonly MEMORY_SEARCH_ERROR: "memory:search:error"; readonly TASK_LOAD_START: "task:load:start"; readonly TASK_LOAD_COMPLETE: "task:load:complete"; readonly TASK_LOAD_ERROR: "task:load:error"; readonly TASK_SYNC_START: "task:sync:start"; readonly TASK_SYNC_COMPLETE: "task:sync:complete"; readonly TASK_SYNC_ERROR: "task:sync:error"; readonly SESSION_START: "session:start"; readonly SESSION_STOP: "session:stop"; readonly SESSION_CAPTURE_START: "session:capture:start"; readonly SESSION_CAPTURE_COMPLETE: "session:capture:complete"; readonly SESSION_CAPTURE_ERROR: "session:capture:error"; readonly HANDLER_START: "handler:start"; readonly HANDLER_COMPLETE: "handler:complete"; readonly HANDLER_ERROR: "handler:error"; readonly DAL_CONNECT_START: "dal:connect:start"; readonly DAL_CONNECT_COMPLETE: "dal:connect:complete"; readonly DAL_CONNECT_ERROR: "dal:connect:error"; readonly DAL_FALLBACK: "dal:fallback"; readonly MCP_CALL_START: "mcp:call:start"; readonly MCP_CALL_COMPLETE: "mcp:call:complete"; readonly MCP_CALL_ERROR: "mcp:call:error"; }; /** * Type for log event names. */ export type LogEvent = (typeof LogEvents)[keyof typeof LogEvents]; /** * Context fields included in structured logs. * These fields enable correlation and filtering across log entries. */ export interface ILogContext { /** MCP/CLI session identifier */ sessionId?: string; /** Memory group identifier */ groupId?: string; /** Project directory path */ projectRoot?: string; /** Request correlation ID for tracing */ correlationId?: string; /** Current operation being performed */ operation?: string; /** Git branch name */ branch?: string; /** Backend source (mcp, neo4j, zep) */ backend?: string; } /** * Structured log entry for consistent log formatting. */ export interface IStructuredLog { /** Standardized event name */ event: LogEvent | string; /** Log context for correlation */ context?: ILogContext; /** Additional structured data */ data?: Record; /** Operation duration in milliseconds */ durationMs?: number; /** Error message if applicable */ error?: string; } /** * Extended logger interface with structured event logging. */ export interface IStructuredLogger { /** * Log a structured event at info level. * * @param log - Structured log entry * * @example * ```typescript * logger.logEvent({ * event: LogEvents.MEMORY_LOAD_COMPLETE, * context: { sessionId, groupId }, * data: { factCount: 15, nodeCount: 8 }, * durationMs: 234, * }); * ``` */ logEvent(log: IStructuredLog): void; /** * Log a structured event at debug level. */ logEventDebug(log: IStructuredLog): void; /** * Log a structured event at warn level. */ logEventWarn(log: IStructuredLog): void; /** * Log a structured event at error level. */ logEventError(log: IStructuredLog): void; /** * Create a child logger with bound context. * All events logged by the child will include the bound context. * * @param context - Context to bind to all child log entries */ withContext(context: ILogContext): IStructuredLogger; /** * Start a timed operation and return a function to complete it. * Automatically calculates duration when complete() is called. * * @param event - Event name for start/complete logging * @param context - Optional context for the operation * * @example * ```typescript * const complete = logger.startOperation(LogEvents.MEMORY_LOAD_START); * // ... do work ... * complete({ data: { factCount: 15 } }); * ``` */ startOperation(event: LogEvent | string, context?: ILogContext): (result?: { data?: Record; error?: string; }) => void; } /** * Helper to create a correlation ID. * Uses a base36 timestamp and random suffix for uniqueness. */ export declare function generateCorrelationId(): string; /** * Helper to derive the complete event name from a start event. * e.g., 'memory:load:start' -> 'memory:load:complete' */ export declare function deriveCompleteEvent(startEvent: string): string; /** * Helper to derive the error event name from a start event. * e.g., 'memory:load:start' -> 'memory:load:error' */ export declare function deriveErrorEvent(startEvent: string): string; //# sourceMappingURL=IStructuredLog.d.ts.map