|
|
@ -48,7 +48,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
|
message.rstrip! |
|
|
|
message += "\n" unless message.starts_with?('Completed 5') |
|
|
|
end |
|
|
|
"#{CONTENT_PREFIX}#{CONTENT_COLOR_MAP[log.level]}#{message}#{color_map.clear}" |
|
|
|
"#{CONTENT_COLOR_MAP[log.level]}#{message}#{color_map.clear}" |
|
|
|
end |
|
|
|
|
|
|
|
def level |
|
|
@ -67,22 +67,25 @@ class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
|
stack = log.exception.backtrace.select { |line| line.starts_with?(root_path) } |
|
|
|
stack = stack.map { |line| line.delete_prefix("#{root_path}/") } |
|
|
|
|
|
|
|
"#{CONTENT_PREFIX}#{ANSI_REVERSED_ERROR}#{log.exception.class}#{color_map.clear}: #{color}#{log.exception.message}#{color_map.clear}#{backtrace(stack)}" # rubocop:disable Layout/LineLength |
|
|
|
"#{ANSI_REVERSED_ERROR}#{log.exception.class}#{color_map.clear}: #{color}#{log.exception.message}#{color_map.clear}#{backtrace(stack)}" # rubocop:disable Layout/LineLength |
|
|
|
end |
|
|
|
|
|
|
|
def call(log, logger) |
|
|
|
self.color = color_map[log.level] |
|
|
|
self.log = log |
|
|
|
self.logger = logger |
|
|
|
[name, level, tags, named_tags, duration, message, payload, exception].compact.join(' ') |
|
|
|
[before_message, message, payload, exception].compact.join(' ') |
|
|
|
end |
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
def before_message |
|
|
|
[name, level, tags, named_tags, duration, CONTENT_PREFIX].compact.join(' ') |
|
|
|
end |
|
|
|
|
|
|
|
def backtrace(stack) |
|
|
|
nil unless stack.count.positive? |
|
|
|
|
|
|
|
prefix = [name, level, tags, named_tags, duration, message, payload, CONTENT_PREFIX].compact.join(' ') |
|
|
|
"\n#{prefix}#{ANSI_ERROR}↳ #{stack.join("\n#{prefix}#{ANSI_ERROR}↳ ")}#{color_map.clear}" |
|
|
|
"\n#{before_message} #{ANSI_ERROR}↳ #{stack.join("\n#{before_message} #{ANSI_ERROR}↳ ")}#{color_map.clear}" |
|
|
|
end |
|
|
|
end |