# install_log_buffer

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_debug_buffer/install_log_buffer)

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.

## Signature

```python
install_log_buffer(
    target: logging.Logger,
    capacity: int = DEFAULT_CAPACITY,
) -> InMemoryLogBuffer
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `target` | `logging.Logger` | Yes | Logger to attach the buffer to (the package logger). |
| `capacity` | `int` | No | Maximum records to retain. (default: `DEFAULT_CAPACITY`) |

## Returns

`InMemoryLogBuffer`

The installed (or already-installed) buffer handler.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/4bfa52000ef65ac623d8ada0cb67f67cbdd663ea/libs/code/deepagents_code/_debug_buffer.py#L190)