rackspace / gophercloud

A Go SDK for OpenStack. IN FEATURE FREEZE. See Issue #592
http://gophercloud.io
Other
456 stars 185 forks source link

[rfc] Enable Debug Logging of Requests and Results #601

Closed jtopjian closed 8 years ago

jtopjian commented 8 years ago

This commit enables debug logs of the requests and results to be printed if the GOPHERCLOUD_DEBUG environment variable is set.

jtopjian commented 8 years ago

I was working with someone on troubleshooting a Terraform issue. When trying to compare the output of nova --debug or openstack --debug with Terraform / Gophercloud, we noticed there was no easy way to see what was being POST'd. The person I was helping actually used a network sniffer to pull the request 😄

No doubt this isn't the best way to implement this, but thought I'd open the discussion and get some feedback.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.04%) to 81.044% when pulling 1efedd5ec0f761303b2f3432f2ea2f6d1ccbe9c1 on jtopjian:gophercloud-debug into 985a863d6dd5f928b485dbc8ef440813aafa39ad on rackspace:master.

jrperritt commented 8 years ago

This should be handled by providing a custom http.Client to a gophercloud.ProviderClient. See an example of logging and limiting re-auth tries starting here and continuing to the end of the file.

jtopjian commented 8 years ago

If I'm following correctly, any application that uses Gophercloud would need to implement a custom http.Client which provides the logging service?

jrperritt commented 8 years ago

If I'm following correctly, any application that uses Gophercloud would need to implement a custom http.Client which provides the logging service?

Correct. We'd prefer not to dictate what should or shouldn't be logged, or which logger to use, or how many re-auth attempts are tried, etc.

jtopjian commented 8 years ago

Got it. That makes sense.

I would have never figured out how to implement logging outside of what I came up with. Maybe when the new repo is settled, some documentation or a reference logging client can be added?

I'll close this PR. Thank you for walking me through this :)

jrperritt commented 8 years ago

Maybe when the new repo is settled, some documentation or a reference logging client can be added?

Yes, that's a failure on my part.