Class: FluQ::Format::Json

Inherits:
Lines show all
Defined in:
lib/fluq/format/json.rb

Class Method Summary collapse

Methods inherited from Lines

#initialize

Methods inherited from Base

#initialize, #parse

Methods included from Mixins::Loggable

#logger

Constructor Details

This class inherits a constructor from FluQ::Format::Lines

Class Method Details

.to_event(raw) ⇒ Object

See Also:



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fluq/format/json.rb', line 4

def self.to_event(raw)
  case hash = MultiJson.load(raw)
  when Hash
    FluQ::Event.new(hash)
  else
    logger.warn "buffer contained invalid event #{hash.inspect}"
    nil
  end
rescue MultiJson::LoadError
  logger.warn "buffer contained invalid line #{raw.inspect}"
  nil
end