Class: Fluent::TextParser::JSONParser

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/fluent/parser.rb

Instance Attribute Summary

Attributes included from Configurable

#config

Instance Method Summary collapse

Methods included from Configurable

#configure, included, #initialize

Instance Method Details

#call(text) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fluent/parser.rb', line 72

def call(text)
  record = Yajl.load(text)

  if value = record.delete(@time_key)
    if @time_format
      time = Time.strptime(value, @time_format).to_i
    else
      time = value.to_i
    end
  else
    time = Engine.now
  end

  return time, record
rescue Yajl::ParseError
  $log.warn "pattern not match: #{text.inspect}: #{$!}"
  return nil, nil
end