sendgrid / python-http-client

Twilio SendGrid's Python HTTP Client for calling APIs
https://sendgrid.com
MIT License
125 stars 101 forks source link

feat: Use requests Library to Enable Request Logging #142

Closed LaikaN57 closed 4 years ago

LaikaN57 commented 4 years ago

Fixes #141

This PR switches out the underlying HTTP library. Instead of using urllib (and related) which uses http under the hood and does not have configuration options for logging requests, we switch to using the requests library which uses urllib3 under the hood and has a module level logger that we can modify to enable request logging.

Checklist

codecov[bot] commented 4 years ago

Codecov Report

Merging #142 into main will decrease coverage by 0.14%. The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
- Coverage   92.73%   92.59%   -0.15%     
==========================================
  Files           6        6              
  Lines         303      297       -6     
==========================================
- Hits          281      275       -6     
  Misses         22       22              
Impacted Files Coverage Δ
python_http_client/client.py 81.25% <87.50%> (-0.20%) :arrow_down:
tests/test_unit.py 99.24% <100.00%> (-0.03%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1c09a8a...d1374d4. Read the comment docs.

LaikaN57 commented 4 years ago

I am no longer convinced that this was a good idea as it looks like requests uses urllib3 which just uses http. And my original assumption that urllib3 provided header logging was incorrect.

I would instead urge readers to just use this until we can get proper logging in the http: https://stackoverflow.com/a/58769712/11015364