diff --git a/src/kemal/common_log_handler.cr b/src/kemal/common_log_handler.cr index 37a1ea2..99b68ad 100644 --- a/src/kemal/common_log_handler.cr +++ b/src/kemal/common_log_handler.cr @@ -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)