@loglayer/context-manager-linked
Version:
Context manager for loglayer that keeps context between parent and all children.
36 lines (33 loc) • 1.31 kB
text/typescript
import { IContextManager, OnChildLoggerCreatedParams } from '@loglayer/context-manager';
/**
* A context manager that keeps context data synchronized between parent and all children (bi-directional).
*/
declare class LinkedContextManager implements IContextManager {
private contextContainer;
/**
* Sets the context data to be included with every log entry. Set to `undefined` to clear the context data.
*/
setContext(context?: Record<string, any>): void;
/**
* Appends context data to the existing context data.
*/
appendContext(context: Record<string, any>): void;
/**
* Returns the context data to be included with every log entry.
*/
getContext(): Record<string, any>;
/**
* Returns true if context data is present.
*/
hasContextData(): boolean;
/**
* Links the child context manager's context to be the same as the parent context manager's context.
*/
onChildLoggerCreated({ parentContextManager, childContextManager }: OnChildLoggerCreatedParams): void;
/**
* Creates a new instance of the context manager that shares the same context data.
* The clone maintains a bi-directional link with the original context manager.
*/
clone(): IContextManager;
}
export { LinkedContextManager };