Class: DHC::Logging

Inherits:
Interceptor show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/dhc/interceptors/logging.rb

Instance Attribute Summary

Attributes inherited from Interceptor

#request

Instance Method Summary collapse

Methods inherited from Interceptor

#after_request, #all_interceptor_classes, #before_init, #before_response, dup, #initialize, #response

Constructor Details

This class inherits a constructor from DHC::Interceptor

Instance Method Details

#after_responseObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dhc/interceptors/logging.rb', line 23

def after_response
  return unless logger
  logger.info(
    [
      'After DHC response for request',
      "<#{request.object_id}>",
      request.method.upcase,
      "#{request.url} at #{Time.now.iso8601}",
      "Time=#{response.time_ms}ms",
      "URL=#{response.effective_url}",
      request.source ? "\nCalled from #{request.source}" : nil
    ].compact.join(' ')
  )
end

#before_requestObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dhc/interceptors/logging.rb', line 8

def before_request
  return unless logger
  logger.info(
    [
      'Before DHC request',
      "<#{request.object_id}>",
      request.method.upcase,
      "#{request.url} at #{Time.now.iso8601}",
      "Params=#{request.params}",
      "Headers=#{request.headers}",
      request.source ? "\nCalled from #{request.source}" : nil
    ].compact.join(' ')
  )
end