<commit_before>module ImageFetcher
  class Logger
    class << self
      def init_logger(logfile)
        if File.exist?(logfile)
          @@file = logfile
        else
          raise "File doesnt exist"
        end
      end

      def log(message)
        build_logline(message)
        File.open(@@file, 'a') { |log| log.write(build_logline(message)) }
      end

      private :new

      private
      def build_logline(message)
        "#{Time.now} : #{message} \n"
      end
    end
  end
end<commit_msg>wrap basic ruby logger into singleton abstraction<commit_after>require 'logger'

module ImageFetcher
  class Logger
    class << self
      def init_logger(logfile)
        if File.exist?(logfile)
          @@logger ||= ::Logger.new(logfile)
        else
          raise "File doesnt exist"
        end
      end

      def log(message)
        @@logger.add(::Logger::ERROR, message)
      end

      private :new
    end
  end
end
{'fraction_non_alphanumeric': 0.09417989417989418, 'fraction_numerical': 0.0, 'mean_word_length': 1.9748427672955975, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4709974', 'n_tokens_mistral': 292, 'n_tokens_neox': 282, 'n_words': 75}