Skip to content

Commit

Permalink
Merge pull request #25 from DannyBen/fix-log-truncate
Browse files Browse the repository at this point in the history
Fix log being truncated by increasing max packet size
  • Loading branch information
markdascher authored Oct 8, 2018
2 parents 9281091 + 6bcbd54 commit 986442f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/remote_syslog_logger/udp_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 986442f

Please sign in to comment.