class Fluent::DowncaseKeyOutput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_downcase_keys.rb, line 8
def configure conf
  super

  @remove_tag_prefix = /^#{Regexp.escape @remove_tag_prefix}\.?/ if @remove_tag_prefix
end
downcase_keys(record) click to toggle source
# File lib/fluent/plugin/out_downcase_keys.rb, line 26
def downcase_keys record
  new_record = {}

  record.each do |key, value|

    if @deep_rename
      if value.is_a? Hash
        value = downcase_keys value
      elsif value.is_a? Array
        value = value.map { |v| v.is_a?(Hash) ? downcase_keys(v) : v }
      end
    end

    new_record[key.downcase] = value
  end

  new_record
end
emit(tag, es, chain) click to toggle source
# File lib/fluent/plugin/out_downcase_keys.rb, line 14
def emit tag, es, chain
  es.each do |time, record|
    new_tag = @remove_tag_prefix ? tag.sub(@remove_tag_prefix, '') : tag
    new_tag = "#{new_tag}.#{@append_tag}".sub(/^\./, '')
    new_record = downcase_keys record
    Fluent::Engine.emit new_tag, time, new_record
  end

  chain.next
end
get_placeholder(match_data) click to toggle source
# File lib/fluent/plugin/out_downcase_keys.rb, line 45
def get_placeholder match_data
  placeholder = {}

  match_data.to_a.each_with_index do |e, idx|
    placeholder.store "${md[#{idx}]}", e
  end

  placeholder
end