class TinyIRC::AppLogger

Attributes

log[RW]

Public Class Methods

new(app) click to toggle source
# File lib/tinyirc/app.rb, line 9
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/tinyirc/app.rb, line 13
def call(env)
  @start = Time.now
  @status, @headers, @body = @app.call(env)
  @duration = ((Time.now - @start).to_f * 1000).round(2)

  TinyIRC::AppLogger.log.io "#{env['REMOTE_ADDR']} --- #{env['REQUEST_METHOD']} #{env['REQUEST_PATH']} --- #{@duration} ms"

  [@status, @headers, @body]
end