Class: Google::Ads::GoogleAds::Interceptors::LoggingInterceptor
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- Google::Ads::GoogleAds::Interceptors::LoggingInterceptor
- Defined in:
- lib/google/ads/google_ads/interceptors/logging_interceptor.rb
Defined Under Namespace
Classes: CycleFinder
Constant Summary collapse
- HEADERS_TO_MASK =
[:"developer-token"]
- SEARCH_RESPONSE_FIELDS_TO_MASK =
%w[ emailAddress inviterUserEmailAddress userEmail ]
- SEARCH_REQUEST_MASK =
/ customer_user_access.email_address| customer_user_access_invitation.email_address| change_event.user_email| feed.places_location_feed_data.email_address| local_services_lead.contact_details.phone_number| local_services_lead.contact_details.email| local_services_lead.contact_details.consumer_name| local_services_lead_conversation.message_details.text /x
- MASK_REPLACEMENT =
"REDACTED"
Instance Method Summary collapse
-
#initialize(logger) ⇒ LoggingInterceptor
constructor
A new instance of LoggingInterceptor.
- #request_response(request:, call:, method:, metadata: {}) ⇒ Object
- #server_streamer(request:, call:, method:, metadata: {}) ⇒ Object
Constructor Details
#initialize(logger) ⇒ LoggingInterceptor
Returns a new instance of LoggingInterceptor.
49 50 51 52 53 |
# File 'lib/google/ads/google_ads/interceptors/logging_interceptor.rb', line 49 def initialize(logger) # Don't propagate args, parens are necessary super() @logger = logger end |
Instance Method Details
#request_response(request:, call:, method:, metadata: {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/google/ads/google_ads/interceptors/logging_interceptor.rb', line 55 def request_response(request:, call:, method:, metadata: {}) begin response = yield @logger.info { (request, call, method, false) } @logger.debug { (, request) } @logger.debug { (response) } if response.respond_to?(:partial_failure_error) && response.partial_failure_error @logger.debug { (response) } end response rescue Exception @logger.warn { (request, call, method, true) } @logger.info { (, request) } @logger.info { } raise end end |
#server_streamer(request:, call:, method:, metadata: {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/google/ads/google_ads/interceptors/logging_interceptor.rb', line 74 def server_streamer(request:, call:, method:, metadata: {}) begin @logger.info { (request, call, method, false) } responses = yield Enumerator.new do |y| responses.each { |response| @logger.debug { (, request) } @logger.debug { (response) } if response.respond_to?(:partial_failure_error) && response.partial_failure_error @logger.debug { (response) } end y << response } @logger.debug { request_id = call .instance_variable_get(:@wrapped) .instance_variable_get(:@call) .["request-id"] "Request ID for preceding streaming request: #{request_id}" } rescue Exception handle_error(request, call, method, ) end rescue Exception handle_error(request, call, method, ) end end |