Skip to content

Log all streaming chunks for LOG_LEVEL=DEBUG #228

Description

@adubovik

Currently, only chunks related to Choice class are logged.

def send_chunk(self, chunk: BaseChunk) -> None:
log_debug("chunk: " + json.dumps(chunk.to_dict()))
self._queue.put_nowait(chunk)

We need to extend this logging logic uniformly to all kinds of chunks in general so that the debug log shows every single chunk sent to the response stream.

Keep in mind that in the streaming mode we don't need these chunk: logs at all since all the streaming chunks are already logged in this method:

def _format_chunk(data: Union[dict, str]) -> str:
data = "data: " + (
json.dumps(data, separators=(",", ":"))
if isinstance(data, dict)
else data
)
log_debug(data)
return f"{data}\n\n"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions