lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb in google-cloud-memcache-v1beta2-0.9.2 vs lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb in google-cloud-memcache-v1beta2-0.10.0

- old
+ new

@@ -195,18 +195,30 @@ endpoint: @config.endpoint, endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, universe_domain: @config.universe_domain, channel_args: @config.channel_args, interceptors: @config.interceptors, - channel_pool_config: @config.channel_pool + channel_pool_config: @config.channel_pool, + logger: @config.logger ) + @cloud_memcache_stub.stub_logger&.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::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.logger = @cloud_memcache_stub.logger if config.respond_to? :logger= end end ## # Get the associated client for long-running operations. @@ -220,10 +232,19 @@ # # @return [Google::Cloud::Location::Locations::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. # @@ -324,11 +345,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :list_instances, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @cloud_memcache_stub, :list_instances, request, response, operation, options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -412,11 +433,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :get_instance, request, options: options do |response, operation| yield response, operation if block_given? - return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -521,11 +541,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :create_instance, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -620,11 +640,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :update_instance, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -722,11 +742,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :update_parameters, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -818,11 +838,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :delete_instance, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -920,11 +940,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :apply_parameters, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -1022,11 +1042,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :apply_software_update, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -1124,11 +1144,11 @@ retry_policy: @config.retry_policy @cloud_memcache_stub.call_rpc :reschedule_maintenance, request, options: options do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: options yield response, operation if block_given? - return response + throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end @@ -1213,10 +1233,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 @@ -1237,9 +1262,10 @@ config_attr :timeout, nil, ::Numeric, nil config_attr :metadata, nil, ::Hash, nil config_attr :retry_policy, nil, ::Hash, ::Proc, nil config_attr :quota_project, nil, ::String, nil config_attr :universe_domain, nil, ::String, nil + config_attr :logger, :default, ::Logger, nil, :default # @private def initialize parent_config = nil @parent_config = parent_config unless parent_config.nil?