@@ -271,7 +271,7 @@ def _handle_retry_and_timeout(self, endpoint, request, signer):
271271retryable = self ._retry_policy .should_retry (retry_policy_context )
272272if retryable & RetryCondition .NO_RETRY :
273273break
274- logger .debug ("Retry needed Request:%s Retries :%d" ,
274+ logger .debug ("Retry needed. Request:%s Retries :%d" ,
275275request .get_action_name (),retries )
276276retry_policy_context .retryable = retryable
277277time_to_sleep = self ._retry_policy .compute_delay_before_next_retry (retry_policy_context )
@@ -287,19 +287,20 @@ def _handle_single_request(self, endpoint, request, timeout, signer):
287287http_response = self ._make_http_response (endpoint ,request ,timeout ,signer )
288288params = copy .deepcopy (request .get_query_params ())
289289params .pop ('AccessKeyId' ,None )
290- logger .debug ('Request params are %s' ,str (params ))
290+ logger .debug ('Request received. Product:%s Endpoint:%s Params: %s' ,
291+ request .get_product (),endpoint ,str (params ))
291292
292293# Do the actual network thing
293294try :
294295status ,headers ,body = http_response .get_response_object ()
295296except IOError as e :
296- logger .error ("HttpError occurred Host:%s SDK-Version:%s" ,
297- endpoint ,aliyunsdkcore .__version__ )
298297
299298exception = ClientException (error_code .SDK_HTTP_ERROR ,str (e ))
299+ logger .error ("HttpError occurred. Host:%s SDK-Version:%s ClientException:%s" ,
300+ endpoint ,aliyunsdkcore .__version__ ,str (exception ))
300301return None ,None ,None ,exception
301302
302- exception = self ._get_server_exception (status ,body )
303+ exception = self ._get_server_exception (status ,body , endpoint )
303304return status ,headers ,body ,exception
304305
305306@staticmethod
@@ -315,11 +316,11 @@ def _parse_error_info_from_response_body(response_body):
315316error_message_to_return = body_obj ['Message' ]
316317except ValueError :
317318# failed to parse body as json format
318- logger .warning ('Failed to parseResponse:%s as json format.' ,response_body )
319+ logger .warning ('Failed to parseresponse as json format. Response:%s ' ,response_body )
319320
320321return error_code_to_return ,error_message_to_return
321322
322- def _get_server_exception (self ,http_status ,response_body ):
323+ def _get_server_exception (self ,http_status ,response_body , endpoint ):
323324request_id = None
324325
325326try :
@@ -328,29 +329,35 @@ def _get_server_exception(self, http_status, response_body):
328329except (ValueError ,TypeError ,AttributeError ):
329330# in case the response body is not a json string, return the raw
330331# data instead
331- logger .warning ('Failed to parseResponse:%s as json format.' ,response_body )
332+ logger .warning ('Failed to parseresponse as json format. Response:%s ' ,response_body )
332333
333334if http_status < codes .OK or http_status >= codes .MULTIPLE_CHOICES :
334335
335336server_error_code ,server_error_message = self ._parse_error_info_from_response_body (
336337response_body .decode ('utf-8' ))
337- return ServerException (
338+
339+ exception = ServerException (
338340server_error_code ,
339341server_error_message ,
340342http_status = http_status ,
341343request_id = request_id )
342344
345+ logger .error ("ServerException occurred. Host:%s SDK-Version:%s ServerException:%s" ,
346+ endpoint ,aliyunsdkcore .__version__ ,str (exception ))
347+
348+ return exception
349+
343350def do_action_with_exception (self ,acs_request ):
344351
345352# set server response format as json, because this function will
346353# parse the response so which format doesn't matter
347354acs_request .set_accept_format ('JSON' )
348-
349355status ,headers ,body ,exception = self ._implementation_of_do_action (acs_request )
350356
351357if exception :
352358raise exception
353-
359+ logger .debug ('Response received. Product:%s Response-body: %s' ,
360+ acs_request .get_product (),body )
354361return body
355362
356363def _resolve_endpoint (self ,request ):
@@ -396,4 +403,3 @@ def set_file_logger(self, path, log_level=logging.INFO, logger_name='aliyunsdkco
396403formatter = logging .Formatter (self .LOG_FORMAT )
397404fh .setFormatter (formatter )
398405log .addHandler (fh )
399-