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