Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #6 from kenhys/convert-timestamp-to-string
Browse files Browse the repository at this point in the history
Set string expression of timestamp into record

Patch by Kentaro Hayashi. Thanks!!!
  • Loading branch information
kou committed Oct 27, 2017
2 parents 7405fe8 + 0317dfa commit f546b6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/fluent/plugin/parser_groonga_log.rb
Expand Up @@ -36,7 +36,11 @@ def parse(text)
event_time = Fluent::EventTime.from_time(statistic.timestamp)
record = {}
statistic.each_pair do |member, value|
record[member.to_s] = value
if value.kind_of?(Time)
record[member.to_s] = value.iso8601
else
record[member.to_s] = value
end
end
yield event_time, record
end
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_parser_groonga_log.rb
Expand Up @@ -13,7 +13,7 @@ def test_parse
@parser.instance.parse(log) do |time, record|
timestamp = Time.local(2017, 7, 19, 14, 41, 5, 663978)
expected = {
"timestamp" => timestamp,
"timestamp" => timestamp.iso8601,
"log_level" => :notice,
"context_id" => "18c61700",
"message" => "spec:2:update:Object:32(type):8",
Expand Down

0 comments on commit f546b6e

Please sign in to comment.