class Gapic::Rest::ClientStub

def log_response method_name, request_id, try_number, response, is_server_streaming

def log_response method_name, request_id, try_number, response, is_server_streaming
  return unless stub_logger
  stub_logger.info do |entry|
    entry.set_system_name
    entry.set_service
    entry.set "rpcName", method_name
    entry.set "retryAttempt", try_number
    entry.set "requestId", request_id
    if response.is_a? StandardError
      entry.set "exception", response.to_s
      entry.message = "Received error for #{entry.service}.#{method_name} (try #{try_number}): #{response}"
    elsif is_server_streaming
      entry.message = "Receiving stream for #{entry.service}.#{method_name} (try #{try_number})"
    else
      entry.message = "Received response for #{entry.service}.#{method_name} (try #{try_number})"
    end
  end
  return if is_server_streaming || !response.respond_to?(:body)
  body = response.body.to_s
  return if body.empty?
  stub_logger.debug do |entry|
    entry.set "requestId", request_id
    entry.set "response", body
    entry.message = "(response payload as JSON)"
  end
end