Don't use handler as the IO name

This commit is contained in:
Serdar Dogruyol 2017-10-05 19:31:47 +03:00
parent 677dc62832
commit dfd127e1ed

View file

@ -1,22 +1,21 @@
module Kemal
# Kemal::CommonLogHandler uses STDOUT by default and handles the logging of request/response process time.
class CommonLogHandler < Kemal::BaseLogHandler
@handler : IO
@io : IO
def initialize(io : IO = STDOUT)
@handler = io
def initialize(@io : IO = STDOUT)
end
def call(context : HTTP::Server::Context)
time = Time.now
call_next(context)
elapsed_text = elapsed_text(Time.now - time)
@handler << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n"
@io << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n"
context
end
def write(message : String)
@handler << message
@io << message
end
private def elapsed_text(elapsed)