From 49e1a559943418bf00e15a61f52f8fc84f60753f Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Sun, 16 Oct 2016 01:00:07 +0900 Subject: [PATCH 1/2] Fix fluent-cat command to send sub-second precision time --- lib/fluent/command/cat.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/fluent/command/cat.rb b/lib/fluent/command/cat.rb index 2332c4431d..3e74ab3a68 100644 --- a/lib/fluent/command/cat.rb +++ b/lib/fluent/command/cat.rb @@ -16,6 +16,8 @@ require 'optparse' require 'fluent/env' +require 'fluent/time' +require 'fluent/engine' op = OptionParser.new @@ -143,7 +145,7 @@ def write(record) raise ArgumentError, "Input must be a map (got #{record.class})" end - entry = [Time.now.to_i, record] + entry = [Fluent::EventTime.now, record] synchronize { unless write_impl([entry]) # write failed @@ -200,7 +202,8 @@ def write_impl(array) end begin - socket.write [@tag, array].to_msgpack + packer = Fluent::Engine.msgpack_factory.packer + socket.write packer.pack([@tag, array]) socket.flush rescue $stderr.puts "write failed: #{$!}" From a7461f1142fc3a9a215381bc51a468fc44e79d2b Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Mon, 17 Oct 2016 23:59:21 +0900 Subject: [PATCH 2/2] Use MessagePackFactory instead of Engine for getting packer --- lib/fluent/command/cat.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fluent/command/cat.rb b/lib/fluent/command/cat.rb index 3e74ab3a68..cfc49c4f99 100644 --- a/lib/fluent/command/cat.rb +++ b/lib/fluent/command/cat.rb @@ -17,7 +17,7 @@ require 'optparse' require 'fluent/env' require 'fluent/time' -require 'fluent/engine' +require 'fluent/msgpack_factory' op = OptionParser.new @@ -202,7 +202,7 @@ def write_impl(array) end begin - packer = Fluent::Engine.msgpack_factory.packer + packer = Fluent::MessagePackFactory.packer socket.write packer.pack([@tag, array]) socket.flush rescue