lib/fluent/plugin/out_parser.rb in fluent-plugin-multiline-parser-0.1.0 vs lib/fluent/plugin/out_parser.rb in fluent-plugin-multiline-parser-0.1.1
- old
+ new
@@ -50,11 +50,11 @@
method(:parse_multilines)
else
method(:parse_singleline)
end
- @parser = Fluent::Plugin.new_parser(conf['format'])
+ @parser = Fluent::TextParser.new
@parser.estimate_current_event = false
@parser.configure(conf)
if !@time_parse && @parser.parser.respond_to?("time_key=".to_sym)
# disable parse time
@parser.parser.time_key = nil
@@ -64,11 +64,15 @@
end
def parse_singleline(tag, time, record, line)
line.chomp!
@parser.parse(line) do |t,values|
if values
- t ||= time
+ if @time_parse
+ t ||= time
+ else
+ t = time
+ end
r = handle_parsed(tag, record, t, values)
else
log.warn "pattern not match with data #{tag} '#{line}'" unless @suppress_parse_error_log
if @reserve_data
t = time
@@ -78,10 +82,10 @@
end
end
def parse_multilines(tag, time, record, line)
if @@lines_buffer.has_key?(tag)
- matches = @parser.firstline?(line)
+ matches = @parser.parser.firstline?(line)
if matches
index = line.index(matches[0])
if index && index > 0
@@lines_buffer[tag] << line[0..index]
line = line[index..-1]