Sha256: 73d9bab0e704d3e95e9eab5567ecfc6d6897421e30519a6d66183dfbf3de1c8d

Contents?: true

Size: 1.92 KB

Versions: 23

Compression:

Stored size: 1.92 KB

Contents

#
# Fluentd
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#

require 'fluent/plugin/parser'

module Fluent
  module Plugin
    class RegexpParser < Parser
      Plugin.register_parser("regexp", self)

      desc 'Regular expression for matching logs'
      config_param :expression, :regexp
      desc 'Ignore case in matching'
      config_param :ignorecase, :bool, default: false, deprecated: "Use /pattern/i instead, this option is no longer effective"
      desc 'Build regular expression as a multline mode'
      config_param :multiline, :bool, default: false, deprecated: "Use /pattern/m instead, this option is no longer effective"

      config_set_default :time_key, 'time'

      def configure(conf)
        super
        # For compat layer
        if @ignorecase || @multiline
          options = 0
          options |= Regexp::IGNORECASE if @ignorecase
          options |= Regexp::MULTILINE if @multiline
          @expression = Regexp.compile(@expression.source, options)
        end
        @regexp = @expression # For backward compatibility
      end

      def parse(text)
        m = @expression.match(text)
        unless m
          yield nil, nil
          return
        end

        r = {}
        m.names.each do |name|
          if value = m[name]
            r[name] = value
          end
        end

        time, record = convert_values(parse_time(r), r)
        yield time, record
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fluentd-1.4.0-x86-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.4.0-x64-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.4.0 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.3-x64-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.3-x86-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.3 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.2-x86-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.2-x64-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.2 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.1-x86-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.1-x64-mingw32 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.1 lib/fluent/plugin/parser_regexp.rb
fluentd-1.3.0 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.6 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.5 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.5.rc1 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.4 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.4.rc1 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.3 lib/fluent/plugin/parser_regexp.rb
fluentd-1.2.2 lib/fluent/plugin/parser_regexp.rb