Sha256: c3521064c0711dd07b976d04f94781e0e0f974a099818caf617fa9a4d99ca83b
Contents?: true
Size: 710 Bytes
Versions: 1
Compression:
Stored size: 710 Bytes
Contents
require 'time' module Rack module Ougai class LogRequests def initialize(app, logger = nil) @app = app @logger = logger end def call(env) status, headers, body = @app.call(env) ensure logger = @logger || env[RACK_LOGGER] logger.info('HTTP Request', create_log(env, status, headers)) end private def create_log(env, status, header) { time: Time.now, remote_addr: env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"], method: env[REQUEST_METHOD], path: env[PATH_INFO], query: env[QUERY_STRING], status: status.to_i, } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-ougai-0.1.0 | lib/rack/ougai/log_requests.rb |