Sha256: 493840cbed4bc3a1c6ba6a3ba7035dd0a87297d20cea52de3d6ea3989b0e4afa

Contents?: true

Size: 510 Bytes

Versions: 4

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module Acfs
  module Middleware
    # Log requests and responses.
    #
    class Logger < Base
      def initialize(app, options = {})
        super
        @logger = options[:logger] if options[:logger]
      end

      def response(res, nxt)
        logger.info "[ACFS] #{res.request.method.to_s.upcase} #{res.request.url} -> #{res.status}"
        nxt.call res
      end

      def logger
        @logger ||= ::Logger.new STDOUT
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acfs-1.5.1 lib/acfs/middleware/logger.rb
acfs-1.5.0 lib/acfs/middleware/logger.rb
acfs-1.4.0 lib/acfs/middleware/logger.rb
acfs-1.3.4 lib/acfs/middleware/logger.rb