/** * Log context stored in AsyncLocalStorage. * Includes correlation ID and any additional context. */ export interface ILogContext { /** Unique ID for tracing operations across async boundaries */ correlationId: string; /** Additional context data */ [key: string]: unknown; } /** * Generate a new correlation ID. * Uses crypto.randomUUID() for uniqueness. */ export declare function generateCorrelationId(): string; /** * Run a function with a correlation context. * All log entries within the function will include the correlation ID. * * @param fn - Function to run with correlation context * @param existingContext - Optional existing context to extend * @returns The result of the function * * @example * ```typescript * await withCorrelation(async () => { * logger.info('Starting operation'); // includes correlationId * await someAsyncOperation(); * logger.info('Completed'); // same correlationId * }); * ``` */ export declare function withCorrelation(fn: () => T | Promise, existingContext?: Partial): T | Promise; /** * Get the current correlation ID from the async context. * Returns undefined if not within a correlation context. */ export declare function getCorrelationId(): string | undefined; /** * Get the full log context from the async context. * Returns undefined if not within a correlation context. */ export declare function getLogContext(): ILogContext | undefined; /** * Add additional context to the current log context. * Only works if already within a withCorrelation() call. * * @param additionalContext - Context to add */ export declare function extendLogContext(additionalContext: Record): void; //# sourceMappingURL=context.d.ts.map