install_log_buffer(
target: logging.Logger,
capacity: int = DEFAULT_CAPACITY
) -> InMemoryLogBuffer| Name | Type | Description |
|---|---|---|
target* | logging.Logger | Logger to attach the buffer to (the package logger). |
capacity | int | Default: DEFAULT_CAPACITYMaximum records to retain. |
Attach the in-memory buffer handler to target (idempotent).
Lowers target's level to at most INFO so the console shows a useful tail
even when DEEPAGENTS_CODE_DEBUG is off; never raises the level. In
__init__.py this runs before configure_debug_logging, which then sets
the final level (honoring DEEPAGENTS_CODE_DEBUG and
DEEPAGENTS_CODE_LOG_LEVEL) over this INFO floor — so any startup warnings
configure_debug_logging emits are captured by the already-installed buffer.
On a fresh NOTSET logger the NOTSET branch forces INFO without
consulting DEEPAGENTS_CODE_LOG_LEVEL; the > INFO and no env branch only
matters on reconfiguration (e.g. an importlib.reload), where it preserves
an explicit DEEPAGENTS_CODE_LOG_LEVEL rather than clobbering it with INFO.
Lowering the level does not spill log output onto the terminal: because this
handler is present in the propagation chain, Logger.callHandlers finds a
handler (found > 0) and Python's lastResort stderr handler is never
consulted. The exception is an embedding process that attaches its own
INFO-or-lower handler to the root logger, which would then see the
propagated records.
Note: this runs as an import-time side effect (see __init__.py), so every
import deepagents_code attaches the handler and may lower the package
logger's level to INFO for the lifetime of the process.