<commit_before>module Kemal
  # Uses `STDOUT` by default and handles the logging of request/response process time.
  class LogHandler < Kemal::BaseLogHandler
    def initialize(@io : IO = STDOUT)
    end

    def call(context : HTTP::Server::Context)
      elapsed_time = Time.measure { call_next(context) }
      elapsed_text = elapsed_text(elapsed_time)
      @io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n'
      context
    end

    def write(message : String)
      @io << message
    end<commit_msg>Flush io buffer after each write to log (#554)<commit_after>module Kemal
  # Uses `STDOUT` by default and handles the logging of request/response process time.
  class LogHandler < Kemal::BaseLogHandler
    def initialize(@io : IO = STDOUT)
    end

    def call(context : HTTP::Server::Context)
      elapsed_time = Time.measure { call_next(context) }
      elapsed_text = elapsed_text(elapsed_time)
      @io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n'
      @io.flush
      context
    end

    def write(message : String)
      @io << message
      @io.flush
      @io
    end
{'fraction_non_alphanumeric': 0.12490362374710871, 'fraction_numerical': 0.002313030069390902, 'mean_word_length': 3.05625, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4592489', 'n_tokens_mistral': 407, 'n_tokens_neox': 388, 'n_words': 100}