<commit_before>module Travis
  module Worker
    module Util
      module Logging
        def announce(message)
          message.split("\n").each do |msg|
            puts "#{format_logging_header}#{msg}"
          end
        end

        def announce_error
          announce("#{$!.class.name}: #{$!.message}")
          announce($@)
        end

        private
          def format_logging_header
            if header = Thread.current[:logging_header]
              "[#{header}] "
            elsif respond_to?(:logging_header)
              "[#{self.logging_header}] "
            else
              ""
            end
          end
      end
    end
  end
end
<commit_msg>improved and fixed the loggin mixin a little<commit_after>module Travis
  module Worker
    module Util
      module Logging
        def announce(messages)
          messages = messages.split("\n") if messages.is_a?(String)
          messages.each do |msg|
            puts "#{format_logging_header}#{msg}"
          end
        end

        def announce_error
          announce("#{$!.class.name}: #{$!.message}")
          announce($@)
        end

        private
          def format_logging_header
            if header = Thread.current[:logging_header]
              "[#{yellow(header)}] "
            elsif respond_to?(:logging_header)
              "[#{yellow(self.logging_header)}] "
            else
              ""
            end
          end

          def colorize(text, color_code)
            "#{color_code}#{text}\e[0m"
          end

          def red(text);    colorize(text, "\e[31m"); end
          def green(text);  colorize(text, "\e[32m"); end
          def yellow(text); colorize(text, "\e[33m"); end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11232718894009217, 'fraction_numerical': 0.004032258064516129, 'mean_word_length': 1.569526627218935, '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': '4312017', 'n_tokens_mistral': 486, 'n_tokens_neox': 484, 'n_words': 111}