Kouhei Sutou
null+****@clear*****
Thu Sep 28 09:19:30 JST 2017
Kouhei Sutou 2017-09-28 09:19:30 +0900 (Thu, 28 Sep 2017) New Revision: 1d182799c32907a2422bb9d21fe3feabf8a0205f https://github.com/groonga/fluent-plugin-groonga-log/commit/1d182799c32907a2422bb9d21fe3feabf8a0205f Message: Stop to remove timestamp from record Modified files: lib/fluent/plugin/parser_groonga_log.rb test/plugin/test_parser_groonga_log.rb Modified: lib/fluent/plugin/parser_groonga_log.rb (+6 -4) =================================================================== --- lib/fluent/plugin/parser_groonga_log.rb 2017-09-27 19:10:58 +0900 (d3182c1) +++ lib/fluent/plugin/parser_groonga_log.rb 2017-09-28 09:19:30 +0900 (2fc1093) @@ -33,10 +33,12 @@ module Fluent def parse(text) @parser.parse(text) do |statistic| - record = statistic.to_h - timestamp = record.delete(:timestamp) - event_time = Fluent::EventTime.from_time(timestamp) - yield event_time, Hash[record.collect{|k,v| [k.to_s, v]}] + event_time = Fluent::EventTime.from_time(statistic.timestamp) + record = {} + statistic.each_pair do |member, value| + record[member.to_s] = value + end + yield event_time, record end end end Modified: test/plugin/test_parser_groonga_log.rb (+1 -7) =================================================================== --- test/plugin/test_parser_groonga_log.rb 2017-09-27 19:10:58 +0900 (395795c) +++ test/plugin/test_parser_groonga_log.rb 2017-09-28 09:19:30 +0900 (2d3cf22) @@ -13,13 +13,7 @@ class GroongaLogParserTest < Test::Unit::TestCase @parser.instance.parse(log) do |time, record| timestamp = Time.local(2017, 7, 19, 14, 41, 5, 663978) expected = { - "year" => 2017, - "month" => 7, - "day" => 19, - "hour" => 14, - "minute" => 41, - "second" => 5, - "micro_second" => 663978, + "timestamp" => timestamp, "log_level" => :notice, "context_id" => "18c61700", "message" => "spec:2:update:Object:32(type):8", -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170928/c25c63d3/attachment-0001.htm