diff --git a/lib/remote_syslog_logger/udp_sender.rb b/lib/remote_syslog_logger/udp_sender.rb index 867de4a..3e243db 100644 --- a/lib/remote_syslog_logger/udp_sender.rb +++ b/lib/remote_syslog_logger/udp_sender.rb @@ -7,6 +7,7 @@ def initialize(remote_hostname, remote_port, options = {}) @remote_hostname = remote_hostname @remote_port = remote_port @whinyerrors = options[:whinyerrors] + @max_size = options[:max_size] @socket = UDPSocket.new @packet = SyslogProtocol::Packet.new @@ -26,7 +27,8 @@ def transmit(message) next if line =~ /^\s*$/ packet = @packet.dup packet.content = line - @socket.send(packet.assemble, 0, @remote_hostname, @remote_port) + payload = @max_size ? packet.assemble(@max_size) : packet.assemble + @socket.send(payload, 0, @remote_hostname, @remote_port) rescue $stderr.puts "#{self.class} error: #{$!.class}: #{$!}\nOriginal message: #{line}" raise if @whinyerrors