Sha256: e2b7385781222360420365e0eba358de968a897d83e0ac356e5fb6ff0be67b8b

Contents?: true

Size: 805 Bytes

Versions: 10

Compression:

Stored size: 805 Bytes

Contents

#!/usr/bin/env ruby

require 'socket'

class Client
  def initialize(host, port)
    @host = host
    @port = port
  end

  def write_safely(data)
    connect_socket unless @connected
    begin
      @client.puts(data)
    rescue
      @connected = false
    end
  end

  def close
    @client.close if @client && @connected
  end

  private
    def connect_socket
      begin
        @client = TCPSocket.new(@host, @port)
        @connected = true
      rescue
        @connected = false
      end
    end
end

client = Client.new("127.0.0.1", "10000")

while !$stdin.eof?
  line = $stdin.readline
  entries = line.split("\n")
  # Assume that no meaningful line will be less than this
  entries.each do |e|
    if e.length > 10
      client.write_safely(e)
    end
  end
  $stdout.flush
end
client.close

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
nfagent-0.9.31 bin/squid_log_writer
nfagent-0.9.27 bin/squid_log_writer
nfagent-0.9.26 bin/squid_log_writer
nfagent-0.9.20 bin/squid_log_writer
nfagent-0.9.19 bin/squid_log_writer
nfagent-0.9.17 bin/squid_log_writer
nfagent-0.9.15 bin/squid_log_writer
nfagent-0.9.13 bin/squid_log_writer
nfagent-0.9.11 bin/squid_log_writer
nfagent-0.9.10 bin/squid_log_writer