Logs unhandled errors and unhandled promise rejections
Logs messages to different targets: console, HTTP endpoint, or parent app module
Batches non-critical logs (DEBUG, INFO, AUDIT) and flushes on a configurable interval
Sends critical logs (WARN, ERROR, FATAL) immediately without batching
Rate limiting — cap the number of non-critical logs per interval window
Sampling — randomly sample a percentage of non-critical logs to reduce volume
Automatic flush on page unload (beforeunload, pagehide, visibilitychange)
Uses navigator.sendBeacon when available for batched and critical logs; if a batch is rejected, splits it in half and retries recursively, then uses fetch (keepalive) with retries when needed