class LogStash::Codecs::EDN
Public Instance Methods
decode(data) { |new_event(read)| ... }
click to toggle source
# File lib/logstash/codecs/edn.rb, line 26 def decode(data) begin yield targeted_event_factory.new_event(EDN.read(data)) rescue => e @logger.warn("EDN parse failure. Falling back to plain-text", :error => e, :data => data) yield event_factory.new_event("message" => data) end end
encode(event)
click to toggle source
# File lib/logstash/codecs/edn.rb, line 36 def encode(event) # use normalize to make sure returned Hash is pure Ruby # #to_edn which relies on pure Ruby object recognition data = LogStash::Util.normalize(event.to_hash) # timestamp is serialized as a iso8601 string # merge to avoid modifying data which could have side effects if multiple outputs @on_event.call(event, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601).to_edn) end
register()
click to toggle source
# File lib/logstash/codecs/edn.rb, line 21 def register require "edn" end