Create a new Logger instance.
Component name string or options object
Create a child logger with a specific component context. Uses LRU caching to avoid creating new instances while preventing memory leaks.
The component context for the child logger
A cached or new Logger instance
Create a child context that inherits from the current context. Component names are automatically concatenated.
Context values for the child
A new child context
Log a message at DEBUG level.
Log a message at ERROR level.
Get the current context nesting depth.
The current depth
Log a message at INFO level.
Merge additional context with the current context.
Context values to add/override
A new merged context
Run a function within a logging context. All logs within the function will include the context.
The context to use for logging
The function to execute
The result of the function
Log a message at TRACE level.
Log a message at WARN level.
Execute a function with a child context.
Context values for the child scope
The function to execute
The result of the function
Execute a function with an extended context.
Context values to add
The function to execute
The result of the function
StaticclearClear the child logger cache. Useful for testing or when configuration changes.
StaticcloseClose all writers gracefully. Should be called during application shutdown.
Promise that resolves when all writers are closed
StaticresetReset static state (for testing purposes). Fully resets all resources.
Centralized Logger Facade
Coordinates the logging pipeline:
Now uses LoggerResources for DI-enabled resource management, eliminating the static state anti-pattern while maintaining backward compatibility through lazy global initialization.
Example