From ce1a464426914a782d60f21b0c419204f6385f8d Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 5 Jan 2024 13:41:34 +0400 Subject: [PATCH] rails formatter --- lib/formatters/basic_formatter.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb index 6e1e47d..c773759 100644 --- a/lib/formatters/basic_formatter.rb +++ b/lib/formatters/basic_formatter.rb @@ -23,22 +23,30 @@ class BasicFormatter < SemanticLogger::Formatters::Color return unless log.message msg = log.message - prefix = "#{color}--#{color_map.clear}" + prefix = "#{color} #{color_map.clear}" case log.level when :info - "#{prefix} #{SemanticLogger::AnsiColors::WHITE}#{msg}#{color_map.clear}" + "#{prefix}#{SemanticLogger::AnsiColors::WHITE}#{msg}#{color_map.clear}" when :warn - "#{prefix} #{ANSI_REVERSED_WARNING}#{msg}#{color_map.clear}" + "#{prefix}#{ANSI_REVERSED_WARNING}#{msg}#{color_map.clear}" when :error - "#{prefix} #{ANSI_REVERSED_ERROR}#{msg}#{color_map.clear}" + "#{prefix}#{ANSI_REVERSED_ERROR}#{msg}#{color_map.clear}" when :fatal - "#{prefix} #{ANSI_REVERSED_FATAL}#{msg}#{color_map.clear}" + "#{prefix}#{ANSI_REVERSED_FATAL}#{msg}#{color_map.clear}" else - "#{prefix} #{color}#{msg}#{color_map.clear}" + "#{prefix}#{color}#{msg}#{color_map.clear}" end end + def level + "#{color}╣#{log.level.to_s.chr.upcase}╠#{color_map.clear}" + end + + def name + "#{color}#{log.name.ljust(20)}#{color_map.clear}" + end + def process_info fname = file_name_and_line "#{color}[#{fname}]#{color_map.clear}" if fname @@ -64,6 +72,6 @@ class BasicFormatter < SemanticLogger::Formatters::Color self.log = log self.logger = logger - [level, tags, named_tags, duration, name, message, payload, exception].compact.join(' ') + [name, level, tags, named_tags, duration, message, payload, exception].compact.join(' ') end end