You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should implement request logging. SendGrid support will frequent want this information when helping customers debug their application. This information should include what API they are calling, what response code, and what error message we get back.
Possible Solutions
Natively create a logging.Logger object.
Switch to using urllib3 instead of urllib as it has a logging.Logger which can be configured.
Add an option to be able to pass a custom urllib.requests.OpenerDirector or similar.
A workaround I found was setting http.client.HTTPConnection.debuglevel = 1 but this did not seem to work for me in an AWS lambda environment. (I still need to investigate if there is an issue with my code on this though.)
I welcome feedback and would like to know if the community has any objections to adding dependencies (option 1) or changing dependencies (option 2) as I think these are the simplest methods.
@childish-sambino Yeah really anything that just allows us to set logging.getLogger(<3rd-party-module>).setLevel(logging.DEBUG) or similar will do for my particular use-case (and I suspect the majority of use-cases). I do not have a preference on which 3rd party we go with. I will leave that to maintainers to provide direction on the prefered dependency.
@childish-sambino I am no longer convinced this was a good idea. It adds dependencies on multiple 3rd party libraries and it does not actually solve my header logging issues (see #142 (comment) for details).
Also feel free to work off of #142 if you still want to pursue swithing over to requests. The PR just needs some name changes of opener to session, documentation added, and more testing added (although the coverage only fell because we reduced total line count).
Activity
childish-sambino commentedon Jul 28, 2020
What about just migrating to
requestswhich usesurllib3underneath?LaikaN57 commentedon Jul 28, 2020
@childish-sambino Yeah really anything that just allows us to set
logging.getLogger(<3rd-party-module>).setLevel(logging.DEBUG)or similar will do for my particular use-case (and I suspect the majority of use-cases). I do not have a preference on which 3rd party we go with. I will leave that to maintainers to provide direction on the prefered dependency.childish-sambino commentedon Jul 28, 2020
requestsis preferred given that we also use this in the twilio-python library.This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
LaikaN57 commentedon Jul 28, 2020
@childish-sambino I am no longer convinced this was a good idea. It adds dependencies on multiple 3rd party libraries and it does not actually solve my header logging issues (see #142 (comment) for details).
Also feel free to work off of #142 if you still want to pursue swithing over to
requests. The PR just needs some name changes ofopenertosession, documentation added, and more testing added (although the coverage only fell because we reduced total line count).