Sha256: 5bc529ffcab1791030dc5a16798b3afee3c8cb1f2e484e1a9d2666e89c506936
Contents?: true
Size: 891 Bytes
Versions: 3
Compression:
Stored size: 891 Bytes
Contents
require "logstash/codecs/base" require "logstash/util" class LogStash::Codecs::EDN < LogStash::Codecs::Base config_name "edn" milestone 1 def register require "edn" end public def decode(data) begin yield LogStash::Event.new(EDN.read(data)) rescue => e @logger.warn("EDN parse failure. Falling back to plain-text", :error => e, :data => data) yield LogStash::Event.new("message" => data) end end public 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(data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601).to_edn) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstash-codec-edn-0.1.2 | lib/logstash/codecs/edn.rb |
logstash-codec-edn-0.1.1 | lib/logstash/codecs/edn.rb |
logstash-codec-edn-0.1.0 | lib/logstash/codecs/edn.rb |