mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +00:00
Always generate positive object IDs in inspect
Sometimes, object_ids are created as signed Integers which are invalid in `inspect`. By using the default implementation of `Object#to_s`, we can get valid object_ids the same way Ruby itself would have created them. For a motivation of this change, see * https://bugs.ruby-lang.org/issues/13397 * https://github.com/ruby-concurrency/concurrent-ruby/pull/651
This commit is contained in:
parent
4eecc559a4
commit
d6c3111999
@ -47,10 +47,6 @@ module Rackstash
|
|||||||
FIELD_TAGS = 'tags'.freeze
|
FIELD_TAGS = 'tags'.freeze
|
||||||
FIELD_TIMESTAMP = '@timestamp'.freeze
|
FIELD_TIMESTAMP = '@timestamp'.freeze
|
||||||
FIELD_VERSION = '@version'.freeze
|
FIELD_VERSION = '@version'.freeze
|
||||||
|
|
||||||
# @!visibility private
|
|
||||||
# we want to look "native" with our inspect values, 7 for 32-bit, 14 for 64-bit
|
|
||||||
DEFAULT_OBJ_ID_STR_WIDTH = 0.size == 4 ? 7 : 14
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'rackstash/logger'
|
require 'rackstash/logger'
|
||||||
|
|||||||
@ -38,8 +38,8 @@ module Rackstash
|
|||||||
#
|
#
|
||||||
# @return [String] human-redable details about the object.
|
# @return [String] human-redable details about the object.
|
||||||
def inspect
|
def inspect
|
||||||
id_str = (object_id << 1).to_s(16).rjust(DEFAULT_OBJ_ID_STR_WIDTH, '0')
|
id_str = Object.instance_method(:to_s).bind(self).call[2..-2]
|
||||||
"#<#{self.class.name}:0x#{id_str} #{self}>"
|
"#<#{id_str} #{self}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provide a copy of the wrapped {#raw} data in a format allowing direct
|
# Provide a copy of the wrapped {#raw} data in a format allowing direct
|
||||||
|
|||||||
@ -81,8 +81,8 @@ module Rackstash
|
|||||||
|
|
||||||
# @return [String] a string representation of `self`
|
# @return [String] a string representation of `self`
|
||||||
def inspect
|
def inspect
|
||||||
id_str = (object_id << 1).to_s(16).rjust(DEFAULT_OBJ_ID_STR_WIDTH, '0')
|
id_str = Object.instance_method(:to_s).bind(self).call[2..-2]
|
||||||
"#<#{self.class.name}:0x#{id_str} #{self}>"
|
"#<#{id_str} #{self}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Integer] the number of elements in `self`. May be zero.
|
# @return [Integer] the number of elements in `self`. May be zero.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user