Skip to content

Add logging to h2 connection - #240

Closed
yeraydiazdiaz wants to merge 1 commit into
encode:masterfrom
yeraydiazdiaz:debug-h2-yahoo
Closed

yeraydiazdiaz wants to merge 1 commit into
encode:masterfrom
yeraydiazdiaz:debug-h2-yahoo

Conversation

@yeraydiazdiaz

Copy link
Copy Markdown
Contributor

Also bump h2 version to >=3.1.1.

@sethmlarson

Copy link
Copy Markdown
Contributor

I was thinking we'd have DEBUG for everything besides data transfer and then set TRACE for readers / writers with raw data going in and out. What do you think about that?

@yeraydiazdiaz

Copy link
Copy Markdown
Contributor Author

Sorry, I'm not sure what you mean with setting TRACE of readers and writers.

@sethmlarson

Copy link
Copy Markdown
Contributor

Basically the raw data getting sent/received over streams should be logger.trace() and everything else should be logger.debug() because raw data is pretty verbose.

I had an example logging setup on a different dispatcher that I'd like everyone to look at and see what they think.

@yeraydiazdiaz

Copy link
Copy Markdown
Contributor Author

That's what I thought you meant but I there's no trace method in logger? Or am I missing something?

@florimondmanca

florimondmanca commented Aug 23, 2019 •

Copy link
Copy Markdown
Contributor

@yeraydiazdiaz You're right, although it has been suggested before.

Logging levels are extensible though — example inspired from this comment:

# logging.py
import logging
TRACE = 5
logging.addLevelName(TRACE, 'TRACE')

Then you could write:

from ..logging import TRACE

logger.log(TRACE, "Stream [%d] - Received response events: %r", stream_id, data)

Is this the kind of setup you were thinking about, @sethmlarson?

@sethmlarson

Copy link
Copy Markdown
Contributor

Going to close this in favor of #277

Kludex referenced this pull request in pydantic/httpx2 May 11, 2026
* Fix #240 for sync requests

* - Fix #240 for async requests
- Added comments to explain why we use the Host header in http/2

* Blackify async code

* Manually blackify sync code

* Apply suggestions from code review

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

* Autogenerated sync code

Co-authored-by: cdeler <serj.krotov@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants