Logging refactors and improvements #172
Merged
+741
−154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Move response logging to a new
LoggingNetworkResponseclass.This allows us to decide whether to log the response body, based
on whether the caller reads or streams the content. This fixes a
bug introduced by Pull Request #166, where the
LoggingNetworkwould always omit logging the response body.
Add a
network_response_constructorproperty toDefaultNetwork, to make it easier for subclasses to returntheir own
NetworkResponsesubclasses. Use this inLoggingNetwork, to returnLoggingNetworkResponseinstances.Also add it as an optional property on the
Networkinterfaceclass.
In
network_interface.py, switch some usages of@abc.abstractmethodto@abc.abstractproperty. This doesn'tmatter on recent versions of Python 3, but there is a difference
between the two on Python 2, plus it makes the interface
clearer. This is a backwards-compatible change, because the SDK
uses these as properties, so any custom implementations would've
needed to implement these with
propertyanyway.Update the logging format strings in
LoggingNetwork, to makethem more informative and also easier to override (by using
keyword format placeholders instead of positional ones). This is
a breaking change for clients that were overriding these class
attributes.
Add logging for request exceptions in
LoggingNetwork.Use the
LoggingNetworkduring functional tests.Switch some stateful mock fixtures from session scope to
function scope.