8000 add request logging and hooking by tysonholub · Pull Request #385 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

add request logging and hooking #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 20, 2017
Merged

add request logging and hooking #385

merged 3 commits into from
Oct 20, 2017

Conversation

tysonholub
Copy link
Contributor

PR adds request/response logging and request hooks to TwilioHttpClient

try: 8000
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should import things via the compat.py module which handles version specific imports like this for you.

@tysonholub
Copy link
Contributor Author

pushed commit to change urlencode import from twilio.compat

@jingming
Copy link
Contributor

@tysonholub Thank you for your PR! We have made a ticket in our internal tracking system and will get to this as soon as we can.

@@ -47,4 +72,12 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
timeout=timeout,
)

if hasattr(response, 'json') and response.json():
# strip JSON of possible prettyprint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API doesn't pretty print. We probably want to save the loads/dumps cost by just always using response.text.

Copy link
Contributor
@dougblack dougblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, I'd love to get this shipped this week. If you've got the time, responding to comments and resolving conflicts would be great. If not, we can tidy up before we ship on Friday.

@@ -38,7 +45,25 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
session = Session()
session.verify = get_cert_file()

request = Request(method.upper(), url, params=params, data=data, headers=headers, auth=auth)
kwargs = dict(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's just use a dict literal here.

@tysonholub
Copy link
Contributor Author

I should be able to address these issues before Friday. Thanks!

@codejudas codejudas merged commit 31bf309 into twilio:master Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0