lib/heavylog.rb in heavylog-0.0.6 vs lib/heavylog.rb in heavylog-0.0.7
- old
+ new
@@ -74,11 +74,11 @@
end
end
RequestStore.store[:heavylog_buffer] ||= StringIO.new
- if RequestStore.store[:heavylog_buffer].length + message.bytesize > config.message_limit
+ if RequestStore.store[:heavylog_buffer].length + message_size(message) > config.message_limit
RequestStore.store[:heavylog_buffer].truncate(0)
RequestStore.store[:heavylog_buffer].puts(TRUNCATION)
RequestStore.store[:heavylog_truncated] = true
else
RequestStore.store[:heavylog_buffer].puts(message)
@@ -103,9 +103,15 @@
end
def config
return OrderedOptions.new if !application
application.config.heavylog
+ end
+
+ def message_size(message)
+ return message.bytesize if message.respond_to?(:bytesize)
+ return message.map(&:to_s).sum(&:bytesize) if message.is_a?(Array)
+ message.length
end
end
require 'heavylog/railtie' if defined?(Rails)