lib/heavylog.rb in heavylog-0.0.10 vs lib/heavylog.rb in heavylog-0.0.11
- old
+ new
@@ -12,10 +12,11 @@
module Heavylog
module_function
TRUNCATION = "[TRUNCATED]"
+ ANSI_REGEX = /\e\[(\d+)m/.freeze
mattr_accessor :logger, :application, :formatter, :log_level
def setup(app)
self.application = app
@@ -90,10 +91,11 @@
else
progname
end
end
- message = message.gsub(/\e\[(\d+)m/, "")
+ message = message.gsub(ANSI_REGEX, "") if message.respond_to?(:gsub)
+ message = message.map { |m| m.respond_to?(:gsub) ? m.gsub(ANSI_REGEX, "") : m } if message.is_a?(Array)
RequestStore.store[:heavylog_buffer] ||= StringIO.new
if RequestStore.store[:heavylog_buffer].length + message_size(message) > config.message_limit
RequestStore.store[:heavylog_buffer].truncate(0)