|
@ -3,6 +3,7 @@ require 'rainbow' |
|
|
# ColoredFormatter outputs colored message according to severity |
|
|
# ColoredFormatter outputs colored message according to severity |
|
|
class ColoredFormatter < Logger::Formatter |
|
|
class ColoredFormatter < Logger::Formatter |
|
|
def call(severity, _time, _program_name, message) # rubocop:disable Metrics/MethodLength |
|
|
def call(severity, _time, _program_name, message) # rubocop:disable Metrics/MethodLength |
|
|
|
|
|
msg = message.is_a?(String) ? message : message.inspect |
|
|
tint = case severity |
|
|
tint = case severity |
|
|
when 'DEBUG' |
|
|
when 'DEBUG' |
|
|
:darkgray |
|
|
:darkgray |
|
@ -18,6 +19,6 @@ class ColoredFormatter < Logger::Formatter |
|
|
else |
|
|
else |
|
|
raise "unknown severity #{severity}" |
|
|
raise "unknown severity #{severity}" |
|
|
end |
|
|
end |
|
|
"#{Rainbow('╞' + severity.ljust(5) + '╡').bg(:cyan).color(:darkgray)}╠ #{Rainbow(message).color(tint)}\n" |
|
|
|
|
|
|
|
|
"#{Rainbow('╞' + severity.ljust(5) + '╡').bg(:cyan).color(:darkgray)}╠ #{Rainbow(msg).color(tint)}\n" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |