lib/fluent/plugin/out_logentries-tmpfix.rb in fluent-plugin-logentries-tmpfix-0.2.12 vs lib/fluent/plugin/out_logentries-tmpfix.rb in fluent-plugin-logentries-tmpfix-0.2.13.pre

- old
+ new

@@ -18,10 +18,11 @@ config_param :tag_error_log, :string, :default => 'logs-error' config_param :default_token, :string, :default => nil SSL_HOST = "api.logentries.com" NO_SSL_HOST = "data.logentries.com" + HOSTNAME = `hostname`.strip def configure(conf) super @tokens = nil @@ -125,25 +126,25 @@ end def send_logentries(token, data) retries = 0 begin - client.write("#{token} #{data} \n") - rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT, Errno::EPIPE => e + client.write("#{token} #{HOSTNAME} #{data} \n") + rescue Errno::EMSGSIZE + str_length = data.length + send_logentries(token, data[0..str_length/2]) + send_logentries(token, data[(str_length/2)+1..str_length]) + + log.warn "Message Too Long, re-sending it in two part..." + rescue => e if retries < @max_retries retries += 1 @_socket = nil log.warn "Could not push logs to Logentries, resetting connection and trying again. #{e.message}" sleep 5**retries retry end raise ConnectionFailure, "Could not push logs to Logentries after #{retries} retries. #{e.message}" - rescue Errno::EMSGSIZE - str_length = data.length - send_logentries(token, data[0..str_length/2]) - send_logentries(token, data[(str_length/2)+1..str_length]) - - log.warn "Message Too Long, re-sending it in two part..." end end end