Bootstrap¶
How it works¶
ultilog uses lazy bootstrap: logging is configured automatically on the first get_logger() call. No explicit setup is required.
from ultilog import get_logger
log = get_logger() # triggers bootstrap here
log.info("ready")
Configuration order¶
- Default --
get_logger()triggersensure_configured(), which buildsUltilogSettingsfrom defaults and environment variables, then callsconfigure_basic_logging(). - Explicit --
setup(...)pre-configures before first logger use. If logging is already configured,setup()is a no-op unlessforce=True. - Advanced --
configure(settings)accepts a fullUltilogSettingsobject for programmatic control.
Thread safety¶
Bootstrap is protected by a re-entrant lock (threading.RLock). Multiple threads calling get_logger() concurrently will not install duplicate handlers.
Idempotency¶
Configuration runs at most once. Subsequent get_logger() calls skip bootstrap. To reconfigure, pass force=True:
from ultilog import setup
setup(mode="json", force=True) # replaces existing configuration
Reset¶
For tests and notebooks, reset_logging() clears runtime state so bootstrap can run again:
from ultilog import reset_logging
reset_logging()