Skip to content

Commit

Permalink
parser_multiline.rb must require parser_regexp in order to use Fluent…
Browse files Browse the repository at this point in the history
…::Plugin::RegexpParser

Because parser_multiline uses Fluent::Plugin::RegexpParser it must
require parser_regexp, otherwise, you get error messages like this
when using in_tail with format multiline:
```
2017-02-09 02:02:25 +0000 [error]: #0 fluent/supervisor.rb:674:block in main_process: config error file="/etc/fluent/fluent.conf" error_class=Fluent::ConfigError error="Invalid regexp '^(?<time>\\S+\\s+\\S+\\s+\\S+)\\s+(?<host>\\S+)\\s+(?<ident>[\\w\\/\\.\\-]*)(?:\\[(?<pid>[0-9]+)\\])?[^\\:]*\\:\\s*(?<message>.*)$': uninitialized constant Fluent::Plugin::RegexpParser\nDid you mean?  RegexpError"
```
  • Loading branch information
richm committed Feb 9, 2017
1 parent 377cde4 commit 96a9f52
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/fluent/plugin/parser_multiline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

require 'fluent/plugin/parser'
require 'fluent/plugin/parser_regexp'

module Fluent
module Plugin
Expand All @@ -29,13 +30,17 @@ def configure(conf)
super

formats = parse_formats(conf).compact.map { |f| f[1..-2] }.join
$log.error("MultilineParser.configure #{conf} formats orig #{parse_formats(conf).compact} join #{formats}")
begin
regexp = Regexp.new(formats, Regexp::MULTILINE)
$log.error("MultilineParser.configure regexp #{regexp}")
if regexp.named_captures.empty?
raise "No named captures"
end
regexp_conf = Fluent::Config::Element.new("", "", { "expression" => "/#{formats}/", "multiline" => true }, [])
$log.error("MultilineParser.configure regexp_conf #{regexp_conf}")
@parser = Fluent::Plugin::RegexpParser.new
$log.error("MultilineParser.configure parser #{@parser}")
@parser.configure(conf + regexp_conf)
rescue => e
raise Fluent::ConfigError, "Invalid regexp '#{formats}': #{e}"
Expand Down

0 comments on commit 96a9f52

Please sign in to comment.