@loglayer/context-manager-isolated
v2.1.0
Published
Context manager for loglayer that maintains isolated context for each logger instance.
Maintainers
Readme
Isolated Context Manager for LogLayer
A context manager for LogLayer that maintains isolated context for each logger instance. When a child logger is created, it starts with no context data - it does not inherit from the parent.
Installation
npm install @loglayer/context-manager-isolatedyarn add @loglayer/context-manager-isolatedpnpm add @loglayer/context-manager-isolatedQuick Start
import { LogLayer } from "loglayer";
import { IsolatedContextManager } from "@loglayer/context-manager-isolated";
const log = new LogLayer({
// ... other configuration
}).withContextManager(new IsolatedContextManager());
// Set context on parent logger
log.withContext({ userId: "123", requestId: "abc" });
// Create child logger - it will NOT inherit parent context
const childLog = log.child();
// Parent has context
console.log(log.getContext()); // { userId: "123", requestId: "abc" }
// Child starts with empty context
console.log(childLog.getContext()); // {}For more advanced usage and configuration options, visit the documentation.
