lib/remote_syslog/reader.rb in remote_syslog-1.6.0 vs lib/remote_syslog/reader.rb in remote_syslog-1.6.1

- old
+ new

@@ -19,12 +19,17 @@ @buffer = BufferedTokenizer.new @packet = SyslogProtocol::Packet.new - local_hostname = options[:hostname] || (Socket.gethostname rescue `hostname`.chomp) - if local_hostname.nil? || local_hostname.empty? - local_hostname = 'localhost' + if options[:hostname] && options[:hostname] != '' + local_hostname = options[:hostname] + else + local_hostname = (Socket.gethostname rescue `hostname`.chomp)[/^([^\.]+)/, 1] + + if local_hostname.nil? || local_hostname.empty? + local_hostname = 'localhost' + end end @packet.hostname = local_hostname @packet.facility = options[:facility] || 'user' @packet.severity = options[:severity] || 'notice'