Sha256: 2568b071a3cbcb7ce1c6b0046df27fa1add2bc6e11f8684fce5379a8207db3f4

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

class LHC::Logging < LHC::Interceptor

  include ActiveSupport::Configurable
  config_accessor :logger

  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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhc-14.0.0 lib/lhc/interceptors/logging.rb