<NME> tcp.rb
<BEF> ADDFILE
<MSG> - Some small changes to make it easier for testing
- Improve logging from input/output registration
- Add additional way to put logstash in debug: set LOGSTASH_DEBUG in env
- Add tcp output. Writes json-encoded messages

<DFF> @@ -0,0 +1,23 @@
+require "logstash/outputs/base"
+
+class LogStash::Outputs::Tcp < LogStash::Outputs::Base
+  def initialize(url, config={}, &block)
+    super
+  end
+
+  def register
+    # TODO(sissel): Write generic validation methods
+    if !@url.host or !@url.port
+      @logger.fatal("No host or port given in #{self.class}: #{@url}")
+      # TODO(sissel): Make this an actual exception class
+      raise "configuration error"
+    end
+
+    @connection = EventMachine::connect(@url.host, @url.port)
+  end # def register
+
+  def receive(event)
+    @connection.send_data(event.to_hash.to_json)
+    @connection.send_data("\n")
+  end # def receive
+end # class LogStash::Outputs::Tcp

- Some small changes to make it easier for testing - Improve logging from input/output registration - Add additional way to put logstash in debug: set LOGSTASH_DEBUG in env - Add tcp output. Writes json-encoded messages