Handler Manager
Every Logger instance is paired with a dedicated HandlerManager,
an internal module inherited from its LoggerCore.
Where the Logger emits the log, the HandlerManager ensures your logs travel further,
writing to files, sending to remote servers, or reporting to dashboards, wherever needed ๐
It orchestrates all registered log handlers, manages asynchronous tasks,
and provides robust strategies for flushing, cleanup, and error recovery.
- โป๏ธ Handler lifecycle
- Initializes handlers on registration
- Optionally handles errors via a configurable onError callback
- Disposes each handler safely when no longer needed
- ๐ Async task tracking
- Tracks all pending asynchronous log operations
- Ensures that every delivery completes or fails safely
- โฑ๏ธ Flush support
- Call flush(timeout?) to wait for all pending handler tasks
- Supports flushStrategy for time-based or event-driven flushing
- ๐ Error recovery
- Catches errors during log handling
- Reports errors with handler ID and payload context via onError
- ๐งผ Resource cleanup
- dispose() cancels flush strategies, removes all handlers, and clears internal states