From 3c2aa2b119fb484af3bfed0e401596b43421dc91 Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 26 May 2023 22:46:40 +0400 Subject: [PATCH] silence_logger --- config/initializers/silence_logger.rb | 2 ++ lib/formatters/basic_formatter.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config/initializers/silence_logger.rb diff --git a/config/initializers/silence_logger.rb b/config/initializers/silence_logger.rb new file mode 100644 index 0000000..830f750 --- /dev/null +++ b/config/initializers/silence_logger.rb @@ -0,0 +1,2 @@ +Rails.logger.level = :info +ActionView::Base.logger.level = :info diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb index bdda1ac..7ccb437 100644 --- a/lib/formatters/basic_formatter.rb +++ b/lib/formatters/basic_formatter.rb @@ -30,7 +30,11 @@ class BasicFormatter < SemanticLogger::Formatters::Color else log.message end - "#{prefix} #{SemanticLogger::AnsiColors::WHITE}#{message}#{color_map.clear}" + if log.name == "Rails" || log.name == "ActionView::Base" + "#{prefix} #{color}#{message}#{color_map.clear}" + else + "#{prefix} #{SemanticLogger::AnsiColors::WHITE}#{message}#{color_map.clear}" + end when :warn "#{prefix} #{ANSI_REVERSED_WARNING}#{log.message}#{color_map.clear}" when :error, :fatal