Class: LogStash::Codecs::EDN
- Inherits:
-
Base
- Object
- Base
- LogStash::Codecs::EDN
- Defined in:
- lib/logstash/codecs/edn.rb
Instance Method Summary collapse
Instance Method Details
#decode(data) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/logstash/codecs/edn.rb', line 13 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 |
#encode(event) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/logstash/codecs/edn.rb', line 23 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..to_iso8601).to_edn) end |
#register ⇒ Object
8 9 10 |
# File 'lib/logstash/codecs/edn.rb', line 8 def register require "edn" end |