lib/google/cloud/memcache/v1beta2/cloud_memcache/rest/client.rb in google-cloud-memcache-v1beta2-0.9.2 vs lib/google/cloud/memcache/v1beta2/cloud_memcache/rest/client.rb in google-cloud-memcache-v1beta2-0.10.0
- old
+ new
@@ -188,19 +188,31 @@
@cloud_memcache_stub = ::Google::Cloud::Memcache::V1beta2::CloudMemcache::Rest::ServiceStub.new(
endpoint: @config.endpoint,
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
universe_domain: @config.universe_domain,
- credentials: credentials
+ credentials: credentials,
+ logger: @config.logger
)
+ @cloud_memcache_stub.logger(stub: true)&.info do |entry|
+ entry.set_system_name
+ entry.set_service
+ entry.message = "Created client for #{entry.service}"
+ entry.set_credentials_fields credentials
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
+ end
+
@location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
config.credentials = credentials
config.quota_project = @quota_project_id
config.endpoint = @cloud_memcache_stub.endpoint
config.universe_domain = @cloud_memcache_stub.universe_domain
config.bindings_override = @config.bindings_override
+ config.logger = @cloud_memcache_stub.logger if config.respond_to? :logger=
end
end
##
# Get the associated client for long-running operations.
@@ -214,10 +226,19 @@
#
# @return [Google::Cloud::Location::Locations::Rest::Client]
#
attr_reader :location_client
+ ##
+ # The logger used for request/response debug logging.
+ #
+ # @return [Logger]
+ #
+ def logger
+ @cloud_memcache_stub.logger
+ end
+
# Service calls
##
# Lists Instances in a given location.
#
@@ -310,11 +331,10 @@
metadata: @config.metadata,
retry_policy: @config.retry_policy
@cloud_memcache_stub.list_instances request, options do |result, operation|
yield result, operation if block_given?
- return result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -391,11 +411,10 @@
metadata: @config.metadata,
retry_policy: @config.retry_policy
@cloud_memcache_stub.get_instance request, options do |result, operation|
yield result, operation if block_given?
- return result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -493,11 +512,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.create_instance request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -585,11 +604,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.update_instance request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -680,11 +699,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.update_parameters request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -769,11 +788,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.delete_instance request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -864,11 +883,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.apply_parameters request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -959,11 +978,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.apply_software_update request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1054,11 +1073,11 @@
retry_policy: @config.retry_policy
@cloud_memcache_stub.reschedule_maintenance request, options do |result, operation|
result = ::Gapic::Operation.new result, @operations_client, options: options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1134,10 +1153,15 @@
# @!attribute [rw] universe_domain
# The universe domain within which to make requests. This determines the
# default endpoint URL. The default value of nil uses the environment
# universe (usually the default "googleapis.com" universe).
# @return [::String,nil]
+ # @!attribute [rw] logger
+ # A custom logger to use for request/response debug logging, or the value
+ # `:default` (the default) to construct a default logger, or `nil` to
+ # explicitly disable logging.
+ # @return [::Logger,:default,nil]
#
class Configuration
extend ::Gapic::Config
# @private
@@ -1162,9 +1186,10 @@
# Overrides for http bindings for the RPCs of this service
# are only used when this service is used as mixin, and only
# by the host service.
# @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
config_attr :bindings_override, {}, ::Hash, nil
+ config_attr :logger, :default, ::Logger, nil, :default
# @private
def initialize parent_config = nil
@parent_config = parent_config unless parent_config.nil?