class SiteHub::Middleware::Logging::AccessLogger

Constants

FORMAT
STATUS_RANGE
ZERO_STRING

Attributes

logger[R]
start_time[R]

Public Class Methods

new(app, logger = ::Logger.new(STDOUT)) click to toggle source
# File lib/sitehub/middleware/logging/access_logger.rb, line 20
def initialize(app, logger = ::Logger.new(STDOUT))
  @app = app
  @logger = LogWrapper.new(logger)
end

Public Instance Methods

call(env) click to toggle source
# File lib/sitehub/middleware/logging/access_logger.rb, line 25
def call(env)
  request = env[REQUEST] = Request.new(env: env)
  @app.call(env).tap do |response|
    status, headers, body = response.to_a
    response = Response.new(body, status, headers)
    logger.write(RequestLog.new(request, response).to_s)
  end
end