Sha256: b97fa1c613c31340b8797175aa6c1a9f0fc7a87d4bfafd847f783dbbfc8fec72

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 Bytes

Contents

# frozen_string_literal: true

module Sniffer
  module Middleware
    # Response logging build-in middleware
    class Logger
      attr_reader :logger, :severity

      def initialize(logger, severity)
        @logger = logger
        @severity = severity
      end

      def request(_data_item)
        yield
      end

      def response(data_item)
        yield

        return unless logger

        logger.log(severity, data_item.to_json)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sniffer-0.5.0 lib/sniffer/middleware/logger.rb
sniffer-0.4.0 lib/sniffer/middleware/logger.rb