|
|
@ -118,24 +118,29 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
if log.name == 'ActionView::Base' |
|
|
|
log = transform_action_view_base(log) |
|
|
|
elsif log.name == 'Rails' && log.message |
|
|
|
log.message = transform_rails_message(log.message) |
|
|
|
log.message = transform_rails_message(log.message.rstrip) |
|
|
|
end |
|
|
|
log |
|
|
|
end |
|
|
|
|
|
|
|
def transform_rails_message(message) |
|
|
|
message.rstrip! |
|
|
|
case message |
|
|
|
when /^Completed [23]/ |
|
|
|
"#{message}\n" |
|
|
|
when /^Started/ |
|
|
|
md = message.match(/(^Started \w* )"(.*?)"/) |
|
|
|
"#{md.match(1)}#{ANSI_BOLD}#{md.match(2)}#{ANSI_RESET}" |
|
|
|
two_captures_last_as_bold(message, /(^Started \w* )"(.*?)"/) |
|
|
|
when /^Processing/ |
|
|
|
two_captures_last_as_bold(message, /(^Processing by \w*#\w* as )(.*)/) |
|
|
|
else |
|
|
|
message |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def two_captures_last_as_bold(message, regex) |
|
|
|
m1, m2 = message.match(regex).captures |
|
|
|
"#{m1}#{ANSI_BOLD}#{m2}#{ANSI_RESET}" |
|
|
|
end |
|
|
|
|
|
|
|
def transform_action_view_base(log) |
|
|
|
log.level, message = transform_log_debug_lstrip(log) |
|
|
|
message = transform_rendered_message_with_filename(message) |
|
|
|