lib/remote_syslog/cli.rb in remote_syslog-1.2.1 vs lib/remote_syslog/cli.rb in remote_syslog-1.3.0

- old
+ new

@@ -6,10 +6,11 @@ module RemoteSyslog class Cli FIELD_REGEXES = { 'syslog' => /^(\w+ \d+ \S+) (\w+) ([^: ]+):? (.*)$/, + 'rfc3339' => /^(\S+) (\w+) ([^: ]+):? (.*)$/ } def self.process!(argv) c = new(argv) c.parse @@ -79,10 +80,13 @@ @parse_fields = FIELD_REGEXES['syslog'] end opts.on("-s", "--severity SEVERITY", "Severity (notice)") do |v| @severity = v end + opts.on("--tls", "Connect via TCP with TLS") do + @tls = true + end opts.on("--strip-color", "Strip color codes") do @strip_color = true end opts.on_tail("-h", "--help", "Show this message") do puts opts @@ -147,19 +151,22 @@ end end def start EventMachine.run do - socket = EventMachine.open_datagram_socket('0.0.0.0', 0) + if @tls + connection = TlsEndpoint.new(@dest_host, @dest_port) + else + connection = UdpEndpoint.new(@dest_host, @dest_port) + end @files.each do |path| begin EventMachine::file_tail(path, RemoteSyslog::Reader, @dest_host, @dest_port, - :socket => socket, :facility => @facility, + :socket => connection, :facility => @facility, :severity => @severity, :strip_color => @strip_color, :hostname => @hostname, :parse_fields => @parse_fields) - rescue Errno::ENOENT => e puts "#{path} not found, continuing. (#{e.message})" end end end \ No newline at end of file