Skip to content

Commit aa4071c

Browse files
authored
Merge pull request #67 from joker1007/fix-eventtime-impl
Fix EventTime implementation in order to match constructor signature for one in fluentd core
2 parents 46359ba + 42e58ae commit aa4071c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/fluent/logger/fluent_logger.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,25 @@ module Logger
2626
class EventTime
2727
TYPE = 0
2828

29-
def initialize(raw_time)
30-
@time = raw_time
29+
def initialize(sec, nsec = 0)
30+
@sec = sec
31+
@nsec = nsec
3132
end
3233

3334
def to_msgpack(io = nil)
34-
@time.to_i.to_msgpack(io)
35+
@sec.to_msgpack(io)
3536
end
3637

3738
def to_msgpack_ext
38-
[@time.to_i, @time.nsec].pack('NN')
39+
[@sec, @nsec].pack('NN')
3940
end
4041

4142
def self.from_msgpack_ext(data)
4243
new(*data.unpack('NN'))
4344
end
4445

4546
def to_json(*args)
46-
@time.to_i
47+
@sec
4748
end
4849
end
4950

@@ -130,7 +131,7 @@ def post_with_time(tag, map, time)
130131
@logger.debug { "event: #{tag} #{map.to_json}" rescue nil } if @logger.debug?
131132
tag = "#{@tag_prefix}.#{tag}" if @tag_prefix
132133
if @nanosecond_precision && time.is_a?(Time)
133-
write [tag, EventTime.new(time), map]
134+
write [tag, EventTime.new(time.to_i, time.nsec), map]
134135
else
135136
write [tag, time.to_i, map]
136137
end

0 commit comments

Comments
 (0)