<commit_before>require 'logger'
require 'colorize'

module Logging
  @loggers = {}

  def logger
    @logger ||= Logging.logger_for self.class.name
  end

  def self.logger_for(class_name)
    @loggers[class_name] ||= create_logger_for(class_name)
  end

  def self.create_logger_for(class_name)
    logger = Logger.new STDOUT
    logger.progname = class_name
    logger.formatter = LogFormatter.new
    logger
  end

  def self.included(base)
    base.define_singleton_method(:logger) do
      @logger ||= Logging.logger_for self.name
    end
  end

  class LogFormatter < Logger::Formatter
    def call(severity, time, progname, msg)
      color = :default

      case severity
        when 'DEBUG'
          color = :light_blue
        when 'WARN'
          color = :magenta
        when 'INFO'
          color = :cyan
        when 'ERROR'
          color = :light_red
        when 'FATAL'
          color = :light_red
      end

      possible_colors = String.color_codes.keys.delete_if { |sym| sym.to_s.include?("black") || sym.to_s.include?("default") }
      progname_color = possible_colors.sample

      "#{time.strftime("%H:%M:%S")} [#{severity.colorize(color)}] [#{progname.colorize(progname_color)}]: #{msg}\n"
    end
  end
end<commit_msg>Use progname hash instead of a random color for every message<commit_after>require 'logger'
require 'colorize'

module Logging
  @loggers = {}

  def logger
    @logger ||= Logging.logger_for self.class.name
  end

  def self.logger_for(class_name)
    @loggers[class_name] ||= create_logger_for(class_name)
  end

  def self.create_logger_for(class_name)
    logger = Logger.new STDOUT
    logger.progname = class_name
    logger.formatter = LogFormatter.new
    logger
  end

  def self.included(base)
    base.define_singleton_method(:logger) do
      @logger ||= Logging.logger_for self.name
    end
  end

  class LogFormatter < Logger::Formatter
    def call(severity, time, progname, msg)
      color = :default

      case severity
        when 'DEBUG'
          color = :light_blue
        when 'WARN'
          color = :magenta
        when 'INFO'
          color = :cyan
        when 'ERROR'
          color = :light_red
        when 'FATAL'
          color = :light_red
      end

      possible_colors = String.color_codes.keys.delete_if { |sym| sym.to_s.include?("black") || sym.to_s.include?("default") }
      progname_color = possible_colors[progname.hash % possible_colors.length]

      "#{time.strftime("%H:%M:%S")} [#{severity.colorize(color)}] [#{progname.colorize(progname_color)}]: #{msg}\n"
    end
  end
end
{'fraction_non_alphanumeric': 0.11295938104448743, 'fraction_numerical': 0.0, 'mean_word_length': 2.814159292035398, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4455324', 'n_tokens_mistral': 872, 'n_tokens_neox': 835, 'n_words': 180}