Flush io buffer after each write to log (#554)

This commit is contained in:
maggie 2019-10-11 11:14:26 +02:00 committed by Serdar Dogruyol
parent c893172fbf
commit a4bdecdc7d

View file

@ -8,11 +8,14 @@ module Kemal
elapsed_time = Time.measure { call_next(context) } elapsed_time = Time.measure { call_next(context) }
elapsed_text = elapsed_text(elapsed_time) elapsed_text = elapsed_text(elapsed_time)
@io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n' @io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n'
@io.flush
context context
end end
def write(message : String) def write(message : String)
@io << message @io << message
@io.flush
@io
end end
private def elapsed_text(elapsed) private def elapsed_text(elapsed)