@@ -918,25 +918,44 @@ void BlockRequest::OnSuccess(::v1::Response* response) {
918
918
server_code_ = ToPolarisServerCode (response->code ().value ());
919
919
if (server_code_ != kServerCodeServerError ) {
920
920
if (POLARIS_LOG_ENABLE (kTraceLogLevel )) {
921
- POLARIS_LOG (LOG_TRACE, " %s for request[%s] to server[%s:%d] success with response[%s]" ,
922
- PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
923
- instance_->GetHost ().c_str (), instance_->GetPort (), response->ShortDebugString ().c_str ());
921
+ if (instance_ != nullptr ) {
922
+ POLARIS_LOG (LOG_TRACE, " %s for request[%s] to server[%s:%d] success with response[%s]" ,
923
+ PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
924
+ instance_->GetHost ().c_str (), instance_->GetPort (), response->ShortDebugString ().c_str ());
925
+ }else {
926
+ POLARIS_LOG (LOG_TRACE, " %s for request[%s] to server[%s:%d] success with response[%s]" ,
927
+ PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
928
+ host_.c_str (), port_, response->ShortDebugString ().c_str ());
929
+ }
924
930
}
925
931
promise_->SetValue (response);
926
932
} else { // 请求处理失败
927
933
promise_->SetError (kReturnServerError );
928
- POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] error with response[%s]" ,
929
- PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
930
- instance_->GetHost ().c_str (), instance_->GetPort (), response->ShortDebugString ().c_str ());
934
+ if (instance_ != nullptr ) {
935
+ POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] error with response[%s]" ,
936
+ PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
937
+ instance_->GetHost ().c_str (), instance_->GetPort (), response->ShortDebugString ().c_str ());
938
+ }else {
939
+ POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] error with response[%s]" ,
940
+ PolarisRequestTypeStr (request_type_), message_->ShortDebugString ().c_str (),
941
+ host_.c_str (), port_, response->ShortDebugString ().c_str ());
942
+ }
931
943
delete response;
932
944
}
933
945
connector_.UpdateCallResult (this );
934
946
}
935
947
936
948
void BlockRequest::OnFailure (const std::string& message) {
937
- POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] with rpc error %s" , PolarisRequestTypeStr (request_type_),
938
- message_->ShortDebugString ().c_str (), instance_->GetHost ().c_str (), instance_->GetPort (),
939
- message.c_str ());
949
+ if (instance_ != nullptr ) {
950
+ POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] with rpc error %s" , PolarisRequestTypeStr (request_type_),
951
+ message_->ShortDebugString ().c_str (), instance_->GetHost ().c_str (), instance_->GetPort (),
952
+ message.c_str ());
953
+ }else {
954
+ POLARIS_LOG (LOG_ERROR, " %s for request[%s] to server[%s:%d] with rpc error %s" , PolarisRequestTypeStr (request_type_),
955
+ message_->ShortDebugString ().c_str (), host_.c_str (), port_,
956
+ message.c_str ());
957
+ }
958
+
940
959
server_code_ = kServerCodeRpcError ;
941
960
promise_->SetError (kReturnNetworkFailed );
942
961
connector_.UpdateCallResult (this );
0 commit comments