# File lib/fluent/plugin/filter_record_transformer.rb, line 156 def initialize(log) @log = log end
# File lib/fluent/plugin/filter_record_transformer.rb, line 179 def expand(str) str.gsub(/(\${[a-zA-Z0-9_]+(\[-?[0-9]+\])?}|__[A-Z_]+__)/) { log.warn "unknown placeholder `#{$1}` found" unless @placeholders.include?($1) @placeholders[$1] } end
# File lib/fluent/plugin/filter_record_transformer.rb, line 160 def prepare_placeholders(time, record, opts) placeholders = { '${time}' => Time.at(time).to_s } record.each {|key, value| placeholders.store("${#{key}}", value) } opts.each do |key, value| if value.kind_of?(Array) # tag_parts, etc size = value.size value.each_with_index { |v, idx| placeholders.store("${#{key}[#{idx}]}", v) placeholders.store("${#{key}[#{idx-size}]}", v) # support [-1] } else # string, interger, float, and others? placeholders.store("${#{key}}", value) end end @placeholders = placeholders end