Class: Fluent::XmlFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::XmlFilter
- Defined in:
- lib/fluent/plugin/filter_xml_simple.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/fluent/plugin/filter_xml_simple.rb', line 13 def configure(conf) super raise ConfigError, "'Fields' is required" if self.fields.nil? self.fields = self.fields.split(',') raise ConfigError, "'Fields' must contain at least one key" if self.fields.length < 1 end |
#filter(tag, time, record) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fluent/plugin/filter_xml_simple.rb', line 35 def filter(tag, time, record) self.fields.each { |field| if record.key?(field) field_name = field if self.field_name_postfix field_name = [field, self.field_name_postfix].join '_' end hash = @parser.parse(record[field]) hash = self.try_convert_times ? convert_times(hash) : hash $log.debug "Hash from XML: #{hash.to_s}" record[field_name] = hash end } record end |
#shutdown ⇒ Object
29 30 31 32 33 |
# File 'lib/fluent/plugin/filter_xml_simple.rb', line 29 def shutdown super @parser = nil end |
#start ⇒ Object
23 24 25 26 27 |
# File 'lib/fluent/plugin/filter_xml_simple.rb', line 23 def start super @parser = Nori.new(:advanced_typecasting => false) end |