UNPKG

logctx

Version:

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

19 lines (18 loc) 820 B
export declare function configureLoggerContext<T extends () => {}>(contextGetter: () => T): void; /** * Runs a callback function with a specific context. * The context is set using AsyncLocalStorage, allowing the callback to access * the context throughout its execution. * * @param context - The context to run the callback with. * @param callback - The callback function to execute with the provided context. * @template T - The type of the context. */ export declare function runWithContext<T>(context: T, callback: () => void): void; /** * Retrieves the current context from the AsyncLocalStorage. * If no context is set, it returns the default context provided by `getDefaultContext`. * * @returns The current context or the default context if none is set. */ export declare function getContext(): any;