fluent/fluentd — pull request #194 by sonots (2013-09-08 17:50:40+00:00)
Title: (v11) Fix in tail so that it works without time_format

The below configuration does not work in v11 although it works in v10.

type tail
path /var/log/syslog
pos_file /tmp/_var_log_syslog.pos
format /^(?.*)$/
tag raw.syslog

type stdout

It is because in_tail requires `time` not to be nil at https://github.com/fluent/fluentd/blob/v11/lib/fluentd/plugin/in_tail.rb#L89, but v11's RegexpParser returns nil when `time` field does not exist. This patch fixes it as of v10's code at https://github.com/fluent/fluentd/blob/master/lib/fluent/parser.rb#L58

Along the way, I've noticed that the same thing happens for JSONParser and LabeledTSVParser. Adding tests without modification of main codes, following failures occurred. This patch fixes these errors.

1) Fluentd::Plugin::Util::TextParser Fluentd::Plugin::Util::TextParser::RegexpParser can parse log without time
Failure/Error: expect(time).not_to be_nil
expected: not nil
got: nil
# ./spec/plugin/util/text_parser_spec.rb:30:in `block (3 levels) in '

2) Fluentd::Plugin::Util::TextParser Fluentd::Plugin::Util::TextParser::JSONParser can parse json without time
Failure/Error: expect(time).not_to be_nil
expected: not nil
got: nil
# ./spec/plugin/util/text_parser_spec.rb:105:in `block (3 levels) in '

3) Fluentd::Plugin::Util::TextParser Fluentd::Plugin::Util::TextParser::LabeledTSVParser can parses ltsv without time
Failure/Error: time, record = @parser.call("host:192.168.0.1\treq_id:111")
TypeError:
no implicit conversion of nil into String
# ./lib/fluentd/plugin/util/text_parser.rb:120:in `values_map'
# ./lib/fluentd/plugin/util/text_parser.rb:156:in `call'
# ./spec/plugin/util/text_parser_spec.rb:139:in `block (3 levels) in '