diff --git a/src/kemal/common_log_handler.cr b/src/kemal/common_log_handler.cr index 28c23cd..256fcca 100644 --- a/src/kemal/common_log_handler.cr +++ b/src/kemal/common_log_handler.cr @@ -17,9 +17,9 @@ class Kemal::CommonLogHandler < Kemal::BaseLogHandler def call(context) time = Time.now call_next(context) - elapsed = Time.now - time - elapsed_text = elapsed_text(elapsed) - write "#{time} #{context.response.status_code} #{context.request.method} #{context.request.resource} - #{elapsed_text}\n" + elapsed_text = elapsed_text(Time.now - time) + @handler << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n" + @handler.rewind context end @@ -35,12 +35,4 @@ class Kemal::CommonLogHandler < Kemal::BaseLogHandler "#{(millis * 1000).round(2)}µs" end - - def write(message) - if @env == "production" - @handler.write message.to_slice - else - @handler.print message - end - end end