Class: Acfs::Middleware::Logger

Inherits:
Base
  • Object
show all
Defined in:
lib/acfs/middleware/logger.rb

Overview

Log requests and responses.

Instance Attribute Summary

Attributes inherited from Base

#app, #options

Instance Method Summary collapse

Methods inherited from Base

#call

Constructor Details

#initialize(app, options = {}) ⇒ Logger

Returns a new instance of Logger.



10
11
12
13
# File 'lib/acfs/middleware/logger.rb', line 10

def initialize(app, options = {})
  super
  @logger = options[:logger] if options[:logger]
end

Instance Method Details

#loggerObject



20
21
22
# File 'lib/acfs/middleware/logger.rb', line 20

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

#response(res, nxt) ⇒ Object



15
16
17
18
# File 'lib/acfs/middleware/logger.rb', line 15

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