<commit_before>class Loghandler::Client < EM::Connection
  def hostname
    Socket.gethostname
  end

  def local_ip
    orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true  # turn off reverse DNS resolution temporarily
  
    UDPSocket.open do |s|
      s.connect '172.16.31.10', 1
      s.addr.last
    end
    ensure
      Socket.do_not_reverse_lookup = orig
  end
  
  def self.run(options)
    EM.run do
      Signal.trap("INT") do
        EM.stop
      end
      @@options = options
      channel = EventMachine::Channel.new
      channel.subscribe do |data|
          to_send={content:data}.merge(@@options)
          send_data to_send.to_json
      end
      client = EventMachine.connect options[:url], options[:port], Loghandler::Client
      Loghandler::Tailer.new(options,channel)
    end
  end
end
<commit_msg>Added : Channel communication between connection and tailer<commit_after>class Loghandler::Client < EM::Connection
  def hostname
    Socket.gethostname
  end

  def local_ip
    orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true  # turn off reverse DNS resolution temporarily
  
    UDPSocket.open do |s|
      s.connect '172.16.31.10', 1
      s.addr.last
    end
    ensure
      Socket.do_not_reverse_lookup = orig
  end
  
  def self.run(options)
    EM.run do
      Signal.trap("INT") do
        EM.stop
      end
      @@options = options
      channel = EventMachine::Channel.new
      client = EventMachine.connect options[:url], options[:port], Loghandler::Client
      channel.subscribe do |data|
          to_send={content:data}.merge(@@options)
          client.send_data to_send.to_json
      end
      Loghandler::Tailer.new(options,channel)
    end
  end
end

{'fraction_non_alphanumeric': 0.08970672800460035, 'fraction_numerical': 0.011500862564692352, 'mean_word_length': 2.725910064239829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4193314', 'n_tokens_mistral': 563, 'n_tokens_neox': 540, 'n_words': 124}