Sha256: 7e297626751e18c11d8fad948d5eb47bd3142b27a347786702532fce5cd20b34

Contents?: true

Size: 743 Bytes

Versions: 5

Compression:

Stored size: 743 Bytes

Contents

module FlexCommerceApi
  module JsonApiClientExtension
    #
    #
    class LoggingMiddleware < ::Faraday::Middleware
      attr_accessor :request_id, :logger
      def initialize(*args)
        super
        self.request_id = 0
        self.logger = FlexCommerceApi.logger
      end
      #
      #
      def call(env)
        self.request_id += 1
        @app.call(env).on_complete do |response_env|
          logger.debug("FlexApi::Request  id #{request_id} #{env.method.to_s.upcase} #{env.url} started at #{Time.now}")
          logger.debug("\t >>> #{env[:request_body]}") unless  env[:request_body].nil? || env[:request_body].empty?
          logger.debug("\t <<< (#{env[:status]}) #{env.body}")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flex_commerce_api-0.8.3 lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb
flex_commerce_api-0.8.2 lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb
flex_commerce_api-0.8.1 lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb
flex_commerce_api-0.7 lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb
flex_commerce_api-0.6.57 lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb