From f5c53519832883cd82dcc99dce4e49d23d18b6cb Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 24 Jan 2024 11:01:17 +0400 Subject: [PATCH] refactor1 --- lib/formatters/basic_formatter.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb index 52aa33e..4e66e00 100644 --- a/lib/formatters/basic_formatter.rb +++ b/lib/formatters/basic_formatter.rb @@ -121,14 +121,20 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri # transform log before display def transform_log(log) - if log.name == 'ActionView::Base' - log = transform_action_view_base(log) - elsif log.name == 'ActiveRecord::Base' + case log.name + when 'ActionView::Base' then transform_action_view_base(log) + when 'Rails' then transform_rails_log(log) + when 'ActiveRecord::Base' log.message = transform_active_record_message(log.message) - elsif log.name == 'Rails' && log.message - log.message = transform_rails_message(log.message.rstrip) - log.level = :debug if log.message =~ /^#{PREFIX_RAILS_INTERNAL}(Processing|Parameters)/ - end + log + else log end + end + + def transform_rails_log(log) + return log unless log.message + + log.message = transform_rails_message(log.message.rstrip) + log.level = :debug if log.message =~ /^#{PREFIX_RAILS_INTERNAL}(Processing|Parameters)/ log end