Sha256: d6c2bec795fe776e80b5c3b2c3bb61001069622454fe5a6b05556547372f3fd7

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'fluent/plugin/parser_grok'

module Fluent
  class TextParser
    class MultilineGrokParser < GrokParser
      Plugin.register_parser('multiline_grok', self)
      config_param :multiline_start_regexp, :string, :default => nil


      def initialize
        super
      end

      def configure(conf={})
        super
      end

      def has_firstline?
        !!@multiline_start_regexp
      end

      def firstline?(text)
        @multiline_start_regexp && !!@grok.multiline_start_regexp.match(text)
      end

      def parse(text, &block)
        if block_given?
          @grok.parsers.each do |parser|
            parser.parse(text) do |time, record|
              if time and record
                yield time, record
                return
              end
            end
          end
        else
          @grok.parsers.each do |parser|
            parser.parse(text) do |time, record|
              if time and record
                return time, record
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-grok-parser-0.0.4 lib/fluent/plugin/parser_multiline_grok.rb