Class: LogStash::Codecs::Trigger
- Inherits:
-
Base
- Object
- Base
- LogStash::Codecs::Trigger
- Defined in:
- lib/logstash/codecs/trigger.rb
Overview
The “trigger” codec is for reading triggers from a file for later use in trigger-filters.
Instance Method Summary collapse
- #decode(data) {|LogStash::Event.new("message" => @converter.convert(data))| ... } ⇒ Object
- #encode(event) ⇒ Object
- #register ⇒ Object
Instance Method Details
#decode(data) {|LogStash::Event.new("message" => @converter.convert(data))| ... } ⇒ Object
41 42 43 |
# File 'lib/logstash/codecs/trigger.rb', line 41 def decode(data) yield LogStash::Event.new("message" => @converter.convert(data)) end |
#encode(event) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/logstash/codecs/trigger.rb', line 46 def encode(event) if event.include?(@trigger_attribute) event[@trigger_attribute].each do |trigger| dirname = File.dirname(event['path']) basename = File.basename(event['path']) = org.joda.time.DateTime.new(trigger[:timestamp]) triggerfolder = @trigger_folder_prefix + .toString(@trigger_folder_format); path = "#{dirname}/#{triggerfolder}/#{basename}" @logger.debug("Path from trigger", :path => path) if @logger.debug? new_event = event.clone new_event["path"] = path @on_event.call(new_event) end end end |
#register ⇒ Object
35 36 37 38 |
# File 'lib/logstash/codecs/trigger.rb', line 35 def register @converter = LogStash::Util::Charset.new(@charset) @converter.logger = @logger end |