Browse Source

processing redirected

main
pvincent 5 months ago
parent
commit
2eb96f7d1f
  1. 18
      lib/formatters/ansi_formatter.rb

18
lib/formatters/ansi_formatter.rb

@ -40,13 +40,21 @@ class AnsiFormatter < SemanticLogger::Formatters::Color
end end
def reject(log) 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 end
private 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) def alter(log)
if log.name == 'Rails' if log.name == 'Rails'
if log.message if log.message
@ -61,6 +69,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color
end end
log.dimensions = AnsiDimensions.new(rails:, before:) log.dimensions = AnsiDimensions.new(rails:, before:)
@memory = nil @memory = nil
log.message = two_captures_last_as_bold(log.message, /(^Started \w* )"(.*?)"/)
elsif log.message.starts_with?('Completed 2') elsif log.message.starts_with?('Completed 2')
log.dimensions = AnsiDimensions.new(rails: TERMINUS_STRING, after: 1) log.dimensions = AnsiDimensions.new(rails: TERMINUS_STRING, after: 1)
elsif log.message.starts_with?('Completed 3') elsif log.message.starts_with?('Completed 3')
@ -72,6 +81,11 @@ class AnsiFormatter < SemanticLogger::Formatters::Color
log.dimensions = AnsiDimensions.new(rails: "#{draw_fatal}") log.dimensions = AnsiDimensions.new(rails: "#{draw_fatal}")
elsif log.message =~ /^(Processing|Parameters)/ elsif log.message =~ /^(Processing|Parameters)/
log.level = :debug 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 end
elsif log.exception elsif log.exception
log.dimensions = AnsiDimensions.new( log.dimensions = AnsiDimensions.new(

Loading…
Cancel
Save