lib/remote_syslog/cli.rb in remote_syslog-1.4.2 vs lib/remote_syslog/cli.rb in remote_syslog-1.5.0

- old
+ new

@@ -43,15 +43,15 @@ @app_name = m[2] end def parse op = OptionParser.new do |opts| - opts.banner = "Usage: remote_syslog [options] <path to add'l log 1> .. <path to add'l log n>" + opts.banner = "Usage: remote_syslog [options] [<logfile>...]" opts.separator '' opts.separator "Example: remote_syslog -c configs/logs.yml -p 12345 /var/log/mysqld.log" opts.separator '' - opts.separator "Options (default):" + opts.separator "Options:" opts.on("-c", "--configfile PATH", "Path to config (/etc/log_files.yml)") do |v| @configfile = File.expand_path(v) end opts.on("-d", "--dest-host HOSTNAME", "Destination syslog hostname or IP (logs.papertrailapp.com)") do |v| @@ -115,13 +115,11 @@ end def parse_config if File.exist?(@configfile) - config = open(@configfile) do |f| - YAML.load(f) - end + config = YAML.load_file(@configfile) @files += Array(config['files']) if config['destination'] && config['destination']['host'] @dest_host ||= config['destination']['host'] @@ -133,30 +131,38 @@ if config['hostname'] @hostname = config['hostname'] end + @server_cert = config['ssl_server_cert'] + @client_cert_chain = config['ssl_client_cert_chain'] + @client_private_key = config['ssl_client_private_key'] + if config['parse_fields'] @parse_fields = FIELD_REGEXES[config['parse_fields']] || Regexp.new(config['parse_fields']) end end end def run + puts "Watching #{@files.length} files/paths. Sending to #{@dest_host}:#{@dest_port} (#{@tls ? 'TCP/TLS' : 'UDP'})." + if @no_detach start else Daemons.run_proc(@app_name, @daemonize_options) do start end end end def start - puts "Watching #{@files.length} files/paths. Sending to #{@dest_host}:#{@dest_port} (#{@tls ? 'TCP/TLS' : 'UDP'})." EventMachine.run do if @tls - connection = TlsEndpoint.new(@dest_host, @dest_port) + connection = TlsEndpoint.new(@dest_host, @dest_port, + :client_cert_chain => @client_cert_chain, + :client_private_key => @client_private_key, + :server_cert => @server_cert) else connection = UdpEndpoint.new(@dest_host, @dest_port) end @files.each do |path|