7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/fluent/plugin/barito_timber.rb', line 7
def self.create_timber(tag, time, record, trail)
begin
timber = JSON.parse(record[MESSAGE_KEY])
rescue
end
unless timber.is_a?(Hash) then
timber = Hash.new
end
message = record[MESSAGE_KEY] if record.is_a?(Hash) and record.has_key?(MESSAGE_KEY)
client_trail = trail
timestamp = Time.now.utc.strftime('%FT%TZ')
if message.nil? or message.empty?
message = record.to_s
trail.hints << HINTS_NO_MESSAGE
end
timber['tag'] = tag
timber['@message'] = message
timber['@timestamp'] = timestamp
timber['client_trail'] = client_trail.to_hash
timber
end
|