<commit_before>STDOUT.sync = true

def Rails.heroku_stdout_logger
  logger = Logger.new(STDOUT)
  logger.level = Logger.const_get((%w[DEBUG INFO WARN ERROR FATAL UNKNOWN] & [ENV['LOG_LEVEL'].to_s.upcase, "INFO"]).compact.first)
  logger
end

case Rails::VERSION::MAJOR

when 3 then
  Rails.logger = Rails.application.config.logger = Rails.heroku_stdout_logger

when 2 then
  # redefine Rails.logger
  def Rails.logger
    @@logger ||= Rails.heroku_stdout_logger
  end

  # borrowed from Rails::Initializer#initialize_framework_logging
  ([ :active_record, :action_controller, :action_mailer ] & Rails.configuration.frameworks).each do |framework|
    framework.to_s.camelize.constantize.const_get("Base").logger = Rails.logger
  end
  ActiveSupport::Dependencies.logger = Rails.logger
  Rails.cache.logger = Rails.logger
end<commit_msg>Moar DRY and stuff<commit_after>STDOUT.sync = true

def Rails.heroku_stdout_logger
  logger = Logger.new(STDOUT)
  logger.level = Logger.const_get((%w[DEBUG INFO WARN ERROR FATAL UNKNOWN] & [ENV['LOG_LEVEL'].to_s.upcase, "INFO"]).compact.first)
  logger
end

case Rails::VERSION::MAJOR

when 3 then
  Rails.logger = Rails.application.config.logger = Rails.heroku_stdout_logger

when 2 then
  # redefine Rails.logger
  def Rails.logger
    @@logger ||= Rails.heroku_stdout_logger
  end

  # borrowed from Rails::Initializer#initialize_framework_logging
  [ActiveSupport::Dependencies, Rails.cache].concat(
    ([:active_record, :action_controller, :action_mailer] & Rails.configuration.frameworks)\
      .map { |framework| framework.to_s.camelize.constantize.const_get("Base") }
  ).each { |k| k.logger = Rails.logger }
end
{'fraction_non_alphanumeric': 0.11693791440626884, 'fraction_numerical': 0.0024110910186859553, 'mean_word_length': 5.08058608058608, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1573258', 'n_tokens_mistral': 582, 'n_tokens_neox': 533, 'n_words': 106}