<commit_before>require 'logger'

module Larrow::Runner
  # usage:
  # logger = Larrow::Runner::Logger filename
  # logger.level(3).color('red').info 'hello'
  class Logger
    def initialize logger, level:nil, color:nil
      @inner_logger = if logger.is_a? ::Logger
                        logger
                      else
                        ::Logger.new logger
                      end
      @level = level
      @color = color
    end

    def level level
      Logger.new @inner_logger, level: level, color: @color
    end

    def color color
      Logger.new @inner_logger, level: @level, color: color
    end

    def info msg
      indent = "\t" * (@level || 0)
      wrapped = wrap_color msg
      @inner_logger.info "#{indent}#{wrapped}"
    end

    def wrap_color msg
      return msg if @color.nil?
      code = case @color.downcase
               when 'black'   then  '30'
               when 'red'     then  '31'
               when 'green'   then  '32'
               when 'yellow'  then  '33'
               when 'blue'    then  '34'
               when 'magenta' then  '35'
               when 'cyan'    then  '36'
               when 'white'   then  '37'
             end
      "\033[#{code}m#{msg}\033[0m"
    end
  end
end
<commit_msg>log framewoks update<commit_after>require 'logger'

module Larrow::Runner
  # usage:
  # logger = Larrow::Runner::Logger filename
  # logger.level(3).color('red').info 'hello'
  class Logger
    def initialize logger, level:nil, color:nil
      @inner_logger = if logger.is_a? ::Logger
                        logger
                      else
                        ::Logger.new logger
                      end
      @level = level
      @color = color
    end

    def level level
      Logger.new @inner_logger, level: level, color: @color
    end

    def color color
      Logger.new @inner_logger, level: @level, color: color
    end

    def info msg
      indent = "  " * (@level || 0)
      wrapped = wrap_color msg
      @inner_logger.info "#{indent}#{wrapped}"
    end

    def wrap_color msg
      return msg if @color.nil?
      code = case @color.downcase
               when 'black'   then  '30'
               when 'red'     then  '31'
               when 'green'   then  '32'
               when 'yellow'  then  '33'
               when 'blue'    then  '34'
               when 'magenta' then  '35'
               when 'cyan'    then  '36'
               when 'white'   then  '37'
             end
      "\033[#{code}m#{msg}\033[0m"
    end
  end
end

{'fraction_non_alphanumeric': 0.10146071851559416, 'fraction_numerical': 0.01973943939992104, 'mean_word_length': 1.4891944990176817, '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': '786496', 'n_tokens_mistral': 783, 'n_tokens_neox': 748, 'n_words': 223}