Skip to content

Commit

Permalink
Merge pull request #81 from ganmacs/fix-bug-when-nonosecond_precision
Browse files Browse the repository at this point in the history
to_json should return String type
  • Loading branch information
repeatedly authored Jul 1, 2019
2 parents 59fd80d + d92700b commit 2d9feb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/logger/fluent_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.from_msgpack_ext(data)
end

def to_json(*args)
@sec
@sec.to_s
end
end

Expand Down
10 changes: 10 additions & 0 deletions spec/fluent_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@
}
end

context 'when the message has object which does not have #to_msgpack method' do
it 'success with nanosecond' do
expect(logger_with_nanosec.pending_bytesize).to eq(0)
expect(logger_with_nanosec.post('tag', 'a' => Errno::ETIMEDOUT)).to eq(true)
fluentd.wait_transfer
expect(fluentd.queue.last).to eq(['logger-test.tag', { 'a' => 'Errno::ETIMEDOUT' }])
expect(logger_with_nanosec.pending_bytesize).to eq(0)
end
end

it ('close after post') {
expect(logger).to be_connect
logger.close
Expand Down

0 comments on commit 2d9feb5

Please sign in to comment.