Class: Locomotive::Steam::Middlewares::Logging
- Inherits:
-
Object
- Object
- Locomotive::Steam::Middlewares::Logging
- Includes:
- Concerns::Helpers
- Defined in:
- lib/locomotive/steam/middlewares/logging.rb
Overview
Track the request into the current logger
Constant Summary
Constants included from Concerns::Helpers
Concerns::Helpers::CACHE_HEADERS, Concerns::Helpers::HTML_CONTENT_TYPE, Concerns::Helpers::HTML_MIME_TYPES
Instance Method Summary collapse
Methods included from Concerns::Helpers
#html?, #inject_cookies, #json?, #log, #make_local_path, #modify_path, #mounted_on, #redirect_to, #render_response
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/locomotive/steam/middlewares/logging.rb', line 12 def call(env) now = Time.now log "Started #{env['REQUEST_METHOD'].upcase} \"#{env['PATH_INFO']}\" at #{now}".light_white, 0 log "Params: #{env.fetch('steam.request').params.inspect}" app.call(env).tap do |response| done_in_ms = ((Time.now - now) * 10000).truncate / 10.0 log "Completed #{code_to_human(response.first)} in #{done_in_ms}ms\n\n".green end end |