lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.1.0 vs lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.1.1
- old
+ new
@@ -24,11 +24,11 @@
def client
@_socket ||= TCPSocket.new @host, @port
end
- # This method is called when an event reaches to Fluentd.
+ # This method is called when an event reaches Fluentd.
def format(tag, time, record)
return [tag, record].to_msgpack
end
# Scan a given directory for logentries tokens
@@ -42,14 +42,17 @@
end
tokens
end
- # returns the correct token to use for a given tag
- def get_token(tag, tokens)
+ # returns the correct token to use for a given tag / Records
+ def get_token(tag, record, tokens)
+ tag ||= ""
+ record ||= ""
+
tokens.each do |key, value|
- if tag.index(key) != nil then
+ if tag.index(key) != nil || record.index(key) != nil then
return value
end
end
return nil
@@ -60,10 +63,10 @@
tokens = generate_token(@path)
chunk.msgpack_each do |tag, record|
next unless record.is_a? Hash
- token = get_token(tag, tokens)
+ token = get_token(tag, record, tokens)
next if token.nil?
if record.has_key?("message")
send_logentries(record["message"] + ' ' + token)
end