From ea0f459c8d71b9c64d6eef3626bb93a41efc962a Mon Sep 17 00:00:00 2001 From: Neal Collier Date: Fri, 31 May 2024 11:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E6=97=B6core=20dump=E9=97=AE=E9=A2=98=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grpc_server_connector.cpp | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/polaris/plugin/server_connector/grpc_server_connector.cpp b/polaris/plugin/server_connector/grpc_server_connector.cpp index f6d7a6e..ceb27f7 100644 --- a/polaris/plugin/server_connector/grpc_server_connector.cpp +++ b/polaris/plugin/server_connector/grpc_server_connector.cpp @@ -918,25 +918,44 @@ void BlockRequest::OnSuccess(::v1::Response* response) { server_code_ = ToPolarisServerCode(response->code().value()); if (server_code_ != kServerCodeServerError) { if (POLARIS_LOG_ENABLE(kTraceLogLevel)) { - POLARIS_LOG(LOG_TRACE, "%s for request[%s] to server[%s:%d] success with response[%s]", - PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), - instance_->GetHost().c_str(), instance_->GetPort(), response->ShortDebugString().c_str()); + if (instance_ != nullptr) { + POLARIS_LOG(LOG_TRACE, "%s for request[%s] to server[%s:%d] success with response[%s]", + PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), + instance_->GetHost().c_str(), instance_->GetPort(), response->ShortDebugString().c_str()); + }else{ + POLARIS_LOG(LOG_TRACE, "%s for request[%s] to server[%s:%d] success with response[%s]", + PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), + host_.c_str(), port_, response->ShortDebugString().c_str()); + } } promise_->SetValue(response); } else { // 请求处理失败 promise_->SetError(kReturnServerError); - POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] error with response[%s]", - PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), - instance_->GetHost().c_str(), instance_->GetPort(), response->ShortDebugString().c_str()); + if (instance_ != nullptr) { + POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] error with response[%s]", + PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), + instance_->GetHost().c_str(), instance_->GetPort(), response->ShortDebugString().c_str()); + }else{ + POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] error with response[%s]", + PolarisRequestTypeStr(request_type_), message_->ShortDebugString().c_str(), + host_.c_str(), port_, response->ShortDebugString().c_str()); + } delete response; } connector_.UpdateCallResult(this); } void BlockRequest::OnFailure(const std::string& message) { - POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] with rpc error %s", PolarisRequestTypeStr(request_type_), - message_->ShortDebugString().c_str(), instance_->GetHost().c_str(), instance_->GetPort(), - message.c_str()); + if (instance_ != nullptr) { + POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] with rpc error %s", PolarisRequestTypeStr(request_type_), + message_->ShortDebugString().c_str(), instance_->GetHost().c_str(), instance_->GetPort(), + message.c_str()); + }else{ + POLARIS_LOG(LOG_ERROR, "%s for request[%s] to server[%s:%d] with rpc error %s", PolarisRequestTypeStr(request_type_), + message_->ShortDebugString().c_str(), host_.c_str(), port_, + message.c_str()); + } + server_code_ = kServerCodeRpcError; promise_->SetError(kReturnNetworkFailed); connector_.UpdateCallResult(this);