Browse Source

refactor2

main
pvincent 4 months ago
parent
commit
67296b0592
  1. 29
      lib/formatters/basic_formatter.rb

29
lib/formatters/basic_formatter.rb

@ -145,19 +145,22 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri
def transform_rails_message(message)
case message
when /^Completed/
transform_rails_completed(message)
when /^Started/
two_captures_last_as_bold(message, /(^Started \w* )"(.*?)"/)
when /^Processing/
"#{PREFIX_RAILS_INTERNAL}#{two_captures_last_as_bold(message, /(^Processing by \w*#\w* as )(.*)/)}"
when / Parameters/
parameters = message.lstrip.match(/Parameters: ({.*}$)/).match(1)
parameters = JSON.parse(parameters.gsub('=>', ':'), symbolize_names: true)
"#{PREFIX_RAILS_INTERNAL}Parameters: #{parameters.ai(ruby19_syntax: true, plain: true, multiline: false)}"
else
message
end
when /^Completed/ then transform_rails_completed(message)
when /^Started/ then two_captures_last_as_bold(message, /(^Started \w* )"(.*?)"/)
when / Parameters/ then transform_rails_parameters(message)
when /^Processing/ then transform_rails_processing(message)
else message end
end
def transform_rails_processing(message)
message = two_captures_last_as_bold(message, /(^Processing by \w*#\w* as )(.*)/)
"#{PREFIX_RAILS_INTERNAL}#{message}"
end
def transform_rails_parameters(message)
parameters = message.lstrip.match(/Parameters: ({.*}$)/).match(1)
parameters = JSON.parse(parameters.gsub('=>', ':'), symbolize_names: true)
"#{PREFIX_RAILS_INTERNAL}Parameters: #{parameters.ai(ruby19_syntax: true, plain: true, multiline: false)}"
end
def transform_rails_completed(message)

Loading…
Cancel
Save