lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.2.3 vs lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.2.4
- old
+ new
@@ -19,10 +19,11 @@
SSL_HOST = "api.logentries.com"
NO_SSL_HOST = "data.logentries.com"
def configure(conf)
super
+
@tokens = nil
@last_edit = Time.at(0)
end
def start
@@ -31,11 +32,11 @@
def shutdown
super
end
- def ssl_client
+ def client
@_socket ||= if @use_ssl
context = OpenSSL::SSL::SSLContext.new
socket = TCPSocket.new SSL_HOST, @port
ssl_client = OpenSSL::SSL::SSLSocket.new socket, context
@@ -113,17 +114,18 @@
next unless record.has_key? "message"
token = get_token(tag, record)
next if token.nil?
- send_logentries(token + ' ' + record["message"])
+ message = record["message"];
+ send_logentries("#{token} #{message} \n")
end
end
def send_logentries(data)
retries = 0
begin
- client.puts data
+ client.write data
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
if retries < @max_retries
retries += 1
@_socket = nil
log.warn "Could not push logs to Logentries, resetting connection and trying again. #{e.message}"