Class: ActiveResource::DetailedLogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/klaviyo_api/detailed_log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#loggerObject



15
16
17
# File 'lib/klaviyo_api/detailed_log_subscriber.rb', line 15

def logger
  ActiveResource::Base.logger
end

#request(event) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/klaviyo_api/detailed_log_subscriber.rb', line 5

def request(event)
  data = event.payload[:data]
  request_body = data.first

  log_level_method = event.payload[:response].code.to_i < 400 ? :info : :error

  send log_level_method, "Request: #{request_body}" if request_body
  send log_level_method, "Response: #{event.payload[:response].body}" unless event.payload[:response].header['content-type'] == 'text/html'
end