class LogStash::Codecs::JSONList

Public Instance Methods

decode(data) { |event| ... } click to toggle source
# File lib/logstash/codecs/json_list.rb, line 18
def decode(data)
  begin
    JSON.parse(data).each do |obj|
      yield LogStash::Event.new(obj)
    end
  rescue JSON::ParserError => e
    @logger.info("JSON parse failure. Falling back to plain-text", :error => e, :data => data)
    yield LogStash::Event.new("message" => event["message"])
  end   
end
encode(data) click to toggle source
# File lib/logstash/codecs/json_list.rb, line 30
def encode(data)
  arr = Array.new
  arr << data
  @on_event.call(arr.to_json)
end
register() click to toggle source
# File lib/logstash/codecs/json_list.rb, line 14
def register
end