|
|
@ -2,6 +2,7 @@ |
|
|
|
class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
|
ANSI_REVERSED_WARNING = "\e[0;30;43m".freeze |
|
|
|
ANSI_REVERSED_ERROR = "\e[1;30;41m".freeze |
|
|
|
ANSI_REVERSED_FATAL = "\e[1;30;45m".freeze |
|
|
|
ANSI_GRAY = "\e[90m".freeze |
|
|
|
|
|
|
|
def initialize |
|
|
@ -9,24 +10,28 @@ class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
|
color_map: ColorMap.new( |
|
|
|
debug: ANSI_GRAY, |
|
|
|
info: SemanticLogger::AnsiColors::GREEN, |
|
|
|
warn: SemanticLogger::AnsiColors::YELLOW |
|
|
|
warn: SemanticLogger::AnsiColors::YELLOW, |
|
|
|
fatal: SemanticLogger::AnsiColors::MAGENTA |
|
|
|
)) |
|
|
|
end |
|
|
|
|
|
|
|
def message |
|
|
|
return unless log.message |
|
|
|
|
|
|
|
msg = log.message |
|
|
|
prefix = "#{color}--#{color_map.clear}" |
|
|
|
|
|
|
|
case log.level |
|
|
|
when :info |
|
|
|
"#{prefix} #{SemanticLogger::AnsiColors::WHITE}#{log.message}#{color_map.clear}" |
|
|
|
"#{prefix} #{SemanticLogger::AnsiColors::WHITE}#{msg}#{color_map.clear}" |
|
|
|
when :warn |
|
|
|
"#{prefix} #{ANSI_REVERSED_WARNING}#{log.message}#{color_map.clear}" |
|
|
|
when :error, :fatal |
|
|
|
"#{prefix} #{ANSI_REVERSED_ERROR}#{log.message}#{color_map.clear}" |
|
|
|
"#{prefix} #{ANSI_REVERSED_WARNING}#{msg}#{color_map.clear}" |
|
|
|
when :error |
|
|
|
"#{prefix} #{ANSI_REVERSED_ERROR}#{msg}#{color_map.clear}" |
|
|
|
when :fatal |
|
|
|
"#{prefix} #{ANSI_REVERSED_FATAL}#{msg}#{color_map.clear}" |
|
|
|
else |
|
|
|
"#{prefix} #{color}#{log.message}#{color_map.clear}" |
|
|
|
"#{prefix} #{color}#{msg}#{color_map.clear}" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|