aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python
https://docs.aiohttp.org
Other
15.12k stars 2.02k forks source link

Easy logging for all headers/payload #6630

Closed jbakermk closed 2 months ago

jbakermk commented 2 years ago

Is your feature request related to a problem?

I seem to be struggling to find an easy method to enable logging for all headers and the payload on a request. I see that TraceConfig allows interception of on_request_start but that does not include the payload. Maybe I've missed the documentation, but how do I see the payload sent via a POST?

Describe the solution you'd like

For the typical user who may wish to use the logging module, would it be easier to simply log headers and payload to the logger aiohttp.client, and tell a user to enable debug logging on that package if they wish to see data sent/received?

Describe alternatives you've considered

I've sifted through the source code and I can't see another alternative. I tried enabling DEBUG on the the aiohttp.client package, but no logging appeared.

Related component

Client

Additional context

No response

Code of Conduct

asvetlov commented 2 years ago

Payload could be huge, it can lead to out-of-memory error easily. That's why the library has on_request_chunk_sent / on_response_chunk_received for tracing payload chunks. Please use this API.