Sha256: 5802d5562cf9efcaa601b6e530b7869d0bb4e38b6b383d0ae07d2251922f8bab
Contents?: true
Size: 699 Bytes
Versions: 4
Compression:
Stored size: 699 Bytes
Contents
module Locomotive::Wagon class Server # Track the request into the current logger # class Logging < Middleware def call(env) now = Time.now log "Started #{env['REQUEST_METHOD'].upcase} \"#{env['PATH_INFO']}\" at #{now}" app.call(env).tap do |response| done_in_ms = (Time.now - now) * 1000 log "Completed #{code_to_human(response.first)} in #{done_in_ms}ms\n\n" end end protected 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 404 then '404 Not Found' end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems