> ## Documentation Index
> Fetch the complete documentation index at: https://uom-demo.vercel.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# request_logging

> [<span className="flex items-center gap-1"><Icon icon="external-link"/>View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/tree/main/services/orchestrator/src/react_agent/utils/request_logging.py)

Callback Handler streams to stdout on new llm token.

## react\_agent.utils.request\_logging.LoggingCallbackHandler Objects

```python theme={null}
class LoggingCallbackHandler(BaseCallbackHandler)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L22)

Callback Handler that logs all events to a file in JSON format.

#### LoggingCallbackHandler.\_\_init\_\_

```python theme={null}
def __init__(logs_dir: str = LOGS_DIR,
             log_string_max_length: int = 1000) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L28)

Initialize the callback handler.

#### LoggingCallbackHandler.on\_llm\_start

```python theme={null}
def on_llm_start(serialized: dict[str, Any], prompts: list[str],
                 **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L46)

Run when LLM starts running.

**Arguments**:

* `serialized` - The serialized LLM.
* `prompts` - The prompts to run.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_chat\_model\_start

```python theme={null}
def on_chat_model_start(serialized: dict[str, Any],
                        messages: list[list[BaseMessage]],
                        **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L61)

Run when LLM starts running.

**Arguments**:

* `serialized` - The serialized LLM.
* `messages` - The messages to run.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_llm\_end

```python theme={null}
def on_llm_end(response: LLMResult, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L94)

Run when LLM ends running.

**Arguments**:

* `response` - The response from the LLM.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_llm\_error

```python theme={null}
def on_llm_error(error: BaseException, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L109)

Run when LLM errors.

**Arguments**:

* `error` - The error that occurred.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_chain\_start

```python theme={null}
def on_chain_start(serialized: dict[str, Any], inputs: dict[str, Any],
                   **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L121)

Run when a chain starts running.

**Arguments**:

* `serialized` - The serialized chain.
* `inputs` - The inputs to the chain.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_chain\_end

```python theme={null}
def on_chain_end(outputs: dict[str, Any], **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L138)

Run when a chain ends running.

**Arguments**:

* `outputs` - The outputs of the chain.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_chain\_error

```python theme={null}
def on_chain_error(error: BaseException, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L159)

Run when chain errors.

**Arguments**:

* `error` - The error that occurred.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_tool\_start

```python theme={null}
def on_tool_start(serialized: dict[str, Any], input_str: str,
                  **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L171)

Run when the tool starts running.

**Arguments**:

* `serialized` - The serialized tool.
* `input_str` - The input string.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_agent\_action

```python theme={null}
def on_agent_action(action: AgentAction, **kwargs: Any) -> Any
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L186)

Run on agent action.

**Arguments**:

* `action` - The agent action.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_tool\_end

```python theme={null}
def on_tool_end(output: Any, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L195)

Run when tool ends running.

**Arguments**:

* `output` - The output of the tool.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_tool\_error

```python theme={null}
def on_tool_error(error: BaseException, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L226)

Run when tool errors.

**Arguments**:

* `error` - The error that occurred.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_text

```python theme={null}
def on_text(text: str, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L235)

Run on an arbitrary text.

**Arguments**:

* `text` - The text to print.
* `**kwargs` - Additional keyword arguments.

#### LoggingCallbackHandler.on\_agent\_finish

```python theme={null}
def on_agent_finish(finish: AgentFinish, **kwargs: Any) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L244)

Run on the agent end.

**Arguments**:

* `finish` - The agent finish.
* `**kwargs` - Additional keyword arguments.

## react\_agent.utils.request\_logging.LLMRequestLogger Objects

```python theme={null}
class LLMRequestLogger()
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L254)

Logger utility to capture and store detailed HTTP requests and responses to/from LLMs.

It creates structured JSON log files containing full request/response headers, bodies,
methods, and status codes for analysis and troubleshooting.

#### LLMRequestLogger.\_\_init\_\_

```python theme={null}
def __init__()
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L264)

Initialize the logger, create the log directory, and register a file handler with JSON formatting.

#### LLMRequestLogger.log\_request

```python theme={null}
def log_request(request: httpx.Request)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L277)

Log structured details of an outgoing HTTP request.

**Arguments**:

* `request` - The outgoing httpx.Request instance.

#### LLMRequestLogger.log\_response

```python theme={null}
def log_response(response: httpx.Response)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L295)

Log structured details of an incoming HTTP response along with its original request.

**Arguments**:

* `response` - The incoming httpx.Response instance.

## react\_agent.utils.request\_logging.LLMRequestLogger.LogRequest Objects

```python theme={null}
class LogRequest(httpx.Request)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L320)

Custom wrapper for httpx.Request that hooks initialization to log request details immediately.

#### LogRequest.\_\_init\_\_

```python theme={null}
def __init__(*args, **kwargs)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L323)

Initialize the request wrapper and log request method, URL, headers, and body.

## react\_agent.utils.request\_logging.LLMRequestLogger.LogResponse Objects

```python theme={null}
class LogResponse(httpx.Response)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L330)

Custom wrapper for httpx.Response to intercept and optionally log streamed bytes.

#### LogResponse.iter\_bytes

```python theme={null}
def iter_bytes(*args, **kwargs)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L333)

Iterate over response bytes synchronously, yielding each chunk.

**Yields**:

* `bytes` - Chunks of the response body.

#### LogResponse.aiter\_bytes

```python theme={null}
async def aiter_bytes(*args, **kwargs)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L343)

Iterate over response bytes asynchronously, yielding each chunk.

**Yields**:

* `bytes` - Chunks of the response body.

## react\_agent.utils.request\_logging.LLMRequestLogger.LogTransport Objects

```python theme={null}
class LogTransport(httpx.BaseTransport)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L353)

Custom synchronous HTTP transport wrapper to intercept and wrap responses in LogResponse.

#### LogTransport.\_\_init\_\_

```python theme={null}
def __init__(transport: httpx.BaseTransport)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L356)

Initialize the synchronous transport wrapper.

**Arguments**:

* `transport` - The underlying httpx.BaseTransport instance to wrap.

#### LogTransport.handle\_request

```python theme={null}
def handle_request(request: httpx.Request) -> httpx.Response
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L364)

Synchronously handle an HTTP request and wrap the resulting response in LogResponse.

**Arguments**:

* `request` - The outgoing HTTP request.

**Returns**:

* `httpx.Response` - The logged HTTP response.

## react\_agent.utils.request\_logging.LLMRequestLogger.AsyncLogTransport Objects

```python theme={null}
class AsyncLogTransport(httpx.AsyncBaseTransport)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L382)

Custom asynchronous HTTP transport wrapper to intercept and wrap responses in LogResponse.

#### AsyncLogTransport.\_\_init\_\_

```python theme={null}
def __init__(transport: httpx.AsyncBaseTransport)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L385)

Initialize the asynchronous transport wrapper.

**Arguments**:

* `transport` - The underlying httpx.AsyncBaseTransport instance to wrap.

#### AsyncLogTransport.handle\_async\_request

```python theme={null}
async def handle_async_request(request: httpx.Request)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/request_logging.py#L393)

Asynchronously handle an HTTP request and wrap the resulting response in LogResponse.

**Arguments**:

* `request` - The outgoing HTTP request.

**Returns**:

* `httpx.Response` - The logged HTTP response.
