Creates a new ContextManager instance.
Configuration options
Clear global context.
Clear all snapshots.
Clean up resources.
Extract specific fields from context.
Source context
Fields to extract
Extracted context
Flatten nested context to dot notation.
Context to flatten
Optional
prefix: string = ''Key prefix
Flattened context
Get global context.
Global context
Get all snapshots.
All snapshots
Get context statistics.
Context statistics
Merge multiple context objects.
Contexts to merge
Merged context
Restore from a snapshot.
Snapshot to restore
Set global context.
Context to set
Sets a schema for context validation.
The schema to use for validation
Optional
mode: "warn" | "silent" | "throw"Validation mode
Set validation rules.
Validation rules
Create a snapshot of current context.
Optional
metadata: Record<string, unknown>Optional metadata
Created snapshot
Unflatten dot notation to nested object. Converts a flat object with dot-notation keys into a nested object structure.
Flattened context
Nested context
Validate context against rules.
Context to validate
Validation result
ContextManager handles context data for logging.
Features:
ContextManager
Example