|
|
@ -8,6 +8,9 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
NAME_MAX_SIZE = 25 |
|
|
|
TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0 |
|
|
|
CONTENT_PREFIX = ' '.freeze |
|
|
|
PREFIX_RAILS_INTERNAL = '➟ '.freeze |
|
|
|
PREFIX_ACTION_INTERNAL = '↪ '.freeze |
|
|
|
PREFIX_BUG_INTERNAL = '↪ '.freeze |
|
|
|
|
|
|
|
RENDERED_VIEW_DURATION = 100 |
|
|
|
COMPLETED_DURATION = RENDERED_VIEW_DURATION * 5 |
|
|
@ -120,7 +123,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
log = transform_action_view_base(log) |
|
|
|
elsif log.name == 'Rails' && log.message |
|
|
|
log.message = transform_rails_message(log.message.rstrip) |
|
|
|
log.level = :debug if log.message.lstrip =~ /^Processing/ || log.message.lstrip =~ /^Parameters/ |
|
|
|
log.level = :debug if log.message =~ /^#{PREFIX_RAILS_INTERNAL}(Processing|Parameters)/ |
|
|
|
end |
|
|
|
log |
|
|
|
end |
|
|
@ -132,7 +135,9 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
when /^Started/ |
|
|
|
two_captures_last_as_bold(message, /(^Started \w* )"(.*?)"/) |
|
|
|
when /^Processing/ |
|
|
|
" #{two_captures_last_as_bold(message, /(^Processing by \w*#\w* as )(.*)/)}" |
|
|
|
"#{PREFIX_RAILS_INTERNAL}#{two_captures_last_as_bold(message, /(^Processing by \w*#\w* as )(.*)/)}" |
|
|
|
when / Parameters/ |
|
|
|
"#{PREFIX_RAILS_INTERNAL}#{message.lstrip}" |
|
|
|
else |
|
|
|
message |
|
|
|
end |
|
|
@ -155,7 +160,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
log.level, message = transform_log_debug_lstrip(log) |
|
|
|
message = transform_rendered_message_with_filename(message) |
|
|
|
message = transform_duration_strip(message) |
|
|
|
log.message = message |
|
|
|
log.message = "#{PREFIX_ACTION_INTERNAL}#{message}" |
|
|
|
log |
|
|
|
end |
|
|
|
|
|
|
@ -169,7 +174,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
def transform_rendered_message_with_filename(message) |
|
|
|
md = message.match(/^Rendered( layout| collection of|) (.*?\.erb)/) |
|
|
|
filename = "app/views/#{md.match(2)}" |
|
|
|
log.message = " Rendered#{md.match(1)} #{filename}#{md.post_match}" |
|
|
|
log.message = "Rendered#{md.match(1)} #{filename}#{md.post_match}" |
|
|
|
end |
|
|
|
|
|
|
|
def transform_log_debug_lstrip(log) |
|
|
@ -202,7 +207,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
def backtrace(stack) |
|
|
|
return "\n" unless stack.count.positive? |
|
|
|
|
|
|
|
"\n#{before_message} #{ANSI_ERROR}↳ #{stack.join("\n#{before_message} #{ANSI_ERROR}↳ ")}#{color_map.clear}\n" |
|
|
|
"\n#{before_message}#{ANSI_ERROR}#{PREFIX_BUG_INTERNAL}#{stack.join("\n#{before_message}#{ANSI_ERROR}#{PREFIX_BUG_INTERNAL}")}#{color_map.clear}\n" |
|
|
|
end |
|
|
|
|
|
|
|
def color_content |
|
|
|