module Fluent::Compat::HandleTagNameMixin

Attributes

add_tag_prefix[RW]
add_tag_suffix[RW]
remove_tag_prefix[RW]
remove_tag_suffix[RW]

Private Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/compat/handle_tag_name_mixin.rb, line 25
def configure(conf)
  super

  @remove_tag_prefix = if conf.has_key?('remove_tag_prefix')
                         Regexp.new('^' + Regexp.escape(conf['remove_tag_prefix']))
                       else
                         nil
                       end

  @remove_tag_suffix = if conf.has_key?('remove_tag_suffix')
                         Regexp.new(Regexp.escape(conf['remove_tag_suffix']) + '$')
                       else
                         nil
                       end

  @add_tag_prefix = conf['add_tag_prefix']
  @add_tag_suffix = conf['add_tag_suffix']
end
filter_record(tag, time, record) click to toggle source
# File lib/fluent/compat/handle_tag_name_mixin.rb, line 44
def filter_record(tag, time, record)
  tag.sub!(@remove_tag_prefix, '') if @remove_tag_prefix
  tag.sub!(@remove_tag_suffix, '') if @remove_tag_suffix
  tag.insert(0, @add_tag_prefix) if @add_tag_prefix
  tag << @add_tag_suffix if @add_tag_suffix
  super(tag, time, record)
end