UNPKG

logctx

Version:

A Pino-based logger with context-aware logging using async_hooks

27 lines (26 loc) 909 B
interface LogCtxOptions { headers?: string[]; params?: string[]; queries?: string[]; cookies?: string[]; } interface GenericRequest { headers?: Record<string, any>; query?: Record<string, any>; cookies?: Record<string, any>; params?: Record<string, any>; method?: string; path?: string; url?: string; } /** * Middleware to create a context logger for a request. * It extracts specified headers, query parameters, and cookies, * and runs the next middleware with the context set. * * @param request - The incoming request object. * @param next - The next middleware function to call. * @param options - Options to specify which headers, queries, and cookies to include in the context. */ export declare function createContextLogger<T = any>(request: T extends GenericRequest ? T : GenericRequest, next: () => void, options?: LogCtxOptions): void; export {};