diff --git a/lib/formatters/ansi_formatter.rb b/lib/formatters/ansi_formatter.rb index 6259e48..138c010 100644 --- a/lib/formatters/ansi_formatter.rb +++ b/lib/formatters/ansi_formatter.rb @@ -40,13 +40,21 @@ class AnsiFormatter < SemanticLogger::Formatters::Color end def reject(log) - return true if log.name == 'ActionView::Base' && log.message.starts_with?(' Rendering') + return true if log.name == 'ActionView::Base' && log.message&.starts_with?(' Rendering') - true if log.name == 'Rails' && log.message.starts_with?('Loaded') + true if log.name == 'Rails' && log.message&.starts_with?('Loaded') end private + def two_captures_last_as_bold(message, regex) + match = message.match(regex) + return "unmatched: #{message}" unless match + + m1, m2 = match.captures + "#{m1}#{BOLD}#{m2}#{CLEAR}" + end + def alter(log) if log.name == 'Rails' if log.message @@ -61,6 +69,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color end log.dimensions = AnsiDimensions.new(rails:, before:) @memory = nil + log.message = two_captures_last_as_bold(log.message, /(^Started \w* )"(.*?)"/) elsif log.message.starts_with?('Completed 2') log.dimensions = AnsiDimensions.new(rails: TERMINUS_STRING, after: 1) elsif log.message.starts_with?('Completed 3') @@ -72,6 +81,11 @@ class AnsiFormatter < SemanticLogger::Formatters::Color log.dimensions = AnsiDimensions.new(rails: "╙#{draw_fatal}╜") elsif log.message =~ /^(Processing|Parameters)/ log.level = :debug + if log.message =~ /^Processing/ + log.message = two_captures_last_as_bold(log.message, /(^Processing by \w*#\w* as )(.*)/) + end + elsif log.message =~ /Redirected/ + log.message = two_captures_last_as_bold(log.message, /^(Redirected to )http:.*:\d+(.*)/) end elsif log.exception log.dimensions = AnsiDimensions.new(