lib/fluent/plugin/gelf_plugin_util.rb in fluent-plugin-gelf-best-test-1.3.6 vs lib/fluent/plugin/gelf_plugin_util.rb in fluent-plugin-gelf-best-test-1.3.7
- old
+ new
@@ -35,11 +35,11 @@
end
end
def process_record_entry(k, v, conf, gelfentry)
# Truncate values longer than max_bytes
- v = truncate_value(v, conf[:max_bytes])
+ v = (v.respond_to?(:bytesize) && v.bytesize > conf[:max_bytes]) ? "#{v.byteslice(0, conf[:max_bytes] - 3)}..." : v
case k
when 'host', 'hostname'
return {'host' => (conf[:use_record_host] ? v : gelfentry['_host'] = v)}
when 'timestamp', 'time'
@@ -64,15 +64,9 @@
rescue ArgumentError
v
end
end
end
-
- def truncate_value(value, max_bytes)
- value = value.to_s
- value.bytesize > max_bytes ? "#{value.byteslice(0, max_bytes - 15)}tniemy..." : value
- end
-
def ensure_short_message(gelfentry)
return if gelfentry['short_message'] && !gelfentry['short_message'].to_s.strip.empty?
['_message', '_msg', '_log', '_record'].each do |key|