Sha256: 417928bd2aa4dfe8dc6330369cddc26fbfe9b88a7715aa018d820bc06f609f22

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

module Fluent
  module Mixin
    module RewriteTagName
      include RecordFilterMixin
      attr_accessor :tag

      def filter_record(tag, time, record)
        super
        if @tag
          rewrite_tag!(tag)
        end
      end

      def rewrite_tag!(tag)
        placeholder = {
          '${tag}' => tag,
          '__TAG__' => tag
        }
        emit_tag = @tag.gsub(/(\${[a-z_]+(\[[0-9]+\])?}|__[A-Z_]+__)/) do
          $log.warn "RewriteTagNameMixin: unknown placeholder found. :placeholder=>#{$1} :tag=>#{tag} :rewritetag=>#{rewritetag}" unless placeholder.include?($1)
          placeholder[$1]
        end
        tag.gsub!(tag, emit_tag)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-mixin-rewrite-tag-name-0.0.1 lib/fluent/mixin/rewrite_tag_name.rb