Class: LHC::Logging

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

Instance Attribute Summary

Attributes inherited from Interceptor

#request

Instance Method Summary collapse

Methods inherited from Interceptor

#after_request, #before_raw_request, #before_response, dup, #initialize, #response

Constructor Details

This class inherits a constructor from LHC::Interceptor

Instance Method Details

#after_responseObject


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

def after_response
  return unless logger
  logger.info(
    [
      'After LHC 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/lhc/interceptors/logging.rb', line 8

def before_request
  return unless logger
  logger.info(
    [
      'Before LHC 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