3333from googleapiclient .errors import HttpError
3434
3535
36+ LOGGER = logging .getLogger (__name__ )
37+
3638dump_request_response = False
3739
3840
@@ -105,18 +107,18 @@ class BaseModel(Model):
105107 def _log_request (self , headers , path_params , query , body ):
106108 """Logs debugging information about the request if requested."""
107109 if dump_request_response :
108- logging .info ('--request-start--' )
109- logging .info ('-headers-start-' )
110+ LOGGER .info ('--request-start--' )
111+ LOGGER .info ('-headers-start-' )
110112 for h , v in six .iteritems (headers ):
111- logging .info ('%s: %s' , h , v )
112- logging .info ('-headers-end-' )
113- logging .info ('-path-parameters-start-' )
113+ LOGGER .info ('%s: %s' , h , v )
114+ LOGGER .info ('-headers-end-' )
115+ LOGGER .info ('-path-parameters-start-' )
114116 for h , v in six .iteritems (path_params ):
115- logging .info ('%s: %s' , h , v )
116- logging .info ('-path-parameters-end-' )
117- logging .info ('body: %s' , body )
118- logging .info ('query: %s' , query )
119- logging .info ('--request-end--' )
117+ LOGGER .info ('%s: %s' , h , v )
118+ LOGGER .info ('-path-parameters-end-' )
119+ LOGGER .info ('body: %s' , body )
120+ LOGGER .info ('query: %s' , query )
121+ LOGGER .info ('--request-end--' )
120122
121123 def request (self , headers , path_params , query_params , body_value ):
122124 """Updates outgoing requests with a serialized body.
@@ -176,12 +178,12 @@ def _build_query(self, params):
176178 def _log_response (self , resp , content ):
177179 """Logs debugging information about the response if requested."""
178180 if dump_request_response :
179- logging .info ('--response-start--' )
181+ LOGGER .info ('--response-start--' )
180182 for h , v in six .iteritems (resp ):
181- logging .info ('%s: %s' , h , v )
183+ LOGGER .info ('%s: %s' , h , v )
182184 if content :
183- logging .info (content )
184- logging .info ('--response-end--' )
185+ LOGGER .info (content )
186+ LOGGER .info ('--response-end--' )
185187
186188 def response (self , resp , content ):
187189 """Convert the response wire format into a Python object.
@@ -206,7 +208,7 @@ def response(self, resp, content):
206208 return self .no_content_response
207209 return self .deserialize (content )
208210 else :
209- logging .debug ('Content from bad request was: %s' % content )
211+ LOGGER .debug ('Content from bad request was: %s' % content )
210212 raise HttpError (resp , content )
211213
212214 def serialize (self , body_value ):
0 commit comments