class Locomotive::Steam::Middlewares::Logging
Track the request into the current logger
Public Instance Methods
call(env)
click to toggle source
# 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
Protected Instance Methods
code_to_human(code)
click to toggle source
# File lib/locomotive/steam/middlewares/logging.rb, line 26 def code_to_human(code) case code.to_i when 200 then '200 OK' when 301 then '301 Found' when 302 then '302 Found' when 304 then '304 Not Modified' when 404 then '404 Not Found' when 422 then '422 Unprocessable Entity' end end