Class: FunApi::Middleware::RequestLogger
- Inherits:
-
Object
- Object
- FunApi::Middleware::RequestLogger
- Defined in:
- lib/funapi/middleware/request_logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, **options) ⇒ RequestLogger
constructor
A new instance of RequestLogger.
Constructor Details
#initialize(app, **options) ⇒ RequestLogger
Returns a new instance of RequestLogger.
6 7 8 9 10 |
# File 'lib/funapi/middleware/request_logger.rb', line 6 def initialize(app, **) @app = app @logger = [:logger] || Logger.new($stdout) @level = [:level] || :info end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/funapi/middleware/request_logger.rb', line 12 def call(env) start = Time.now status, headers, body = @app.call(env) duration = Time.now - start log_request(env, status, duration) [status, headers, body] end |