<commit_before>module SystemExceptions
  def SystemUtils.log_exception(*args)
    e = args[0]
    e_str = '  BT'
    e.backtrace.each do |bt|
      e_str += bt + " \n"
    end

    args.each do |arg|
      e_str += arg.to_s + ' '
    end
    @@last_error = e_str
    SystemUtils.log_output(e_str, 10)
    e_str +="\n\n"
    elof = File.open("/tmp/exceptions.log", "a+")
    elof.write(e_str)
    elof.close
    SystemUtils.log_exception_to_bugcatcher(e) unless File.exists?(SystemConfig.NoRemoteExceptionLoggingFlagFile)
    EnginesError.new(e_str.to_s, :exception)
  end

  def SystemUtils.log_exception_to_bugcatcher(e)
    require "net/http"
    require "uri"
    SystemDebug.debug(SystemDebug.system, :bug_catcher, e, e.backtrace)
    res = SystemUtils.execute_command('hostname')
    hostname = res[:stdout]
    error_log_hash = {}
    error_log_hash[:message] = e.to_s
    e_str = e.to_s
    e.backtrace.each do |bt|
      e_str += bt + " \n"
    end
    error_log_hash[:backtrace] = e_str
    # error_log_hash[:request_params] = hostname
    error_log_hash[:return_url] = 'system'
    error_log_hash[:user_comment] = ''
    error_log_hash[:user_email] = '<EMAIL>'
    uri = URI.parse('http://buglog.engines.onl/api/v0/contact/bug_reports')
    Net::HTTP.start(uri.host, uri.port) do |http|
      request = Net::HTTP.post_form(uri, error_log_hash)
      response = http.request request # Net::HTTPResponse object
      http.finish
    end
    true
  rescue
    false
  ensure 
    http.finish unless http.nil?
  end

end<commit_msg>bug logger on current<commit_after>module SystemExceptions
  def SystemUtils.log_exception(*args)
    e = args[0]
    e_str = '  BT'
    e.backtrace.each do |bt|
      e_str += bt + " \n"
    end

    args.each do |arg|
      e_str += arg.to_s + ' '
    end
    @@last_error = e_str
    SystemUtils.log_output(e_str, 10)
    e_str +="\n\n"
    elof = File.open("/tmp/exceptions.log", "a+")
    elof.write(e_str)
    elof.close
    SystemUtils.log_exception_to_bugcatcher(e) unless File.exists?(SystemConfig.NoRemoteExceptionLoggingFlagFile)
    EnginesError.new(e_str.to_s, :exception)
  end

  def SystemUtils.log_exception_to_bugcatcher(e)
    require "net/http"
    require "uri"
    SystemDebug.debug(SystemDebug.system, :bug_catcher, e, e.backtrace)
    res = SystemUtils.execute_command('hostname')
    hostname = res[:stdout]
    error_log_hash = {}
    error_log_hash[:message] = e.to_s
    e_str = e.to_s
    e.backtrace.each do |bt|
      e_str += bt + " \n"
    end
    error_log_hash[:backtrace] = e_str
    # error_log_hash[:request_params] = hostname
    error_log_hash[:return_url] = 'system'
    error_log_hash[:user_comment] = ''
    error_log_hash[:user_email] = '<EMAIL>'
    uri = URI.parse('http://buglog.current.engines.org/api/v0/contact/bug_reports')
    Net::HTTP.start(uri.host, uri.port) do |http|
      request = Net::HTTP.post_form(uri, error_log_hash)
      response = http.request request # Net::HTTPResponse object
      http.finish
    end
    true
  rescue
    false
  ensure 
    http.finish unless http.nil?
  end

end
{'fraction_non_alphanumeric': 0.12516170763260026, 'fraction_numerical': 0.00258732212160414, 'mean_word_length': 3.1516778523489934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2884145', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1136, 'n_words': 198}