Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fluent-cat command to send sub-second precision time #1277

Merged
merged 2 commits into from Oct 17, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/fluent/command/cat.rb
Expand Up @@ -16,6 +16,8 @@

require 'optparse'
require 'fluent/env'
require 'fluent/time'
require 'fluent/engine'

op = OptionParser.new

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -200,7 +202,8 @@ def write_impl(array)
end

begin
socket.write [@tag, array].to_msgpack
packer = Fluent::Engine.msgpack_factory.packer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use Fluent::MessagePackFactory.packer than using Fluent::Engine, because it makes internal dependency problem minimized.

socket.write packer.pack([@tag, array])
socket.flush
rescue
$stderr.puts "write failed: #{$!}"
Expand Down