|
|
@ -1,6 +1,6 @@ |
|
|
|
module Semantic |
|
|
|
# My Custom colorized formatter |
|
|
|
class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
|
class BasicFormatter < AbstractFormatter |
|
|
|
ANSI_REVERSED_WARNING = "\e[0;30;43m".freeze |
|
|
|
ANSI_REVERSED_ERROR = "\e[1;30;41m".freeze |
|
|
|
ANSI_GRAY = "\e[90m".freeze |
|
|
@ -57,15 +57,35 @@ module Semantic |
|
|
|
return unless log.exception |
|
|
|
|
|
|
|
root_path = Rails.root.to_s |
|
|
|
backtrace = log.exception.backtrace.select do |line| |
|
|
|
|
|
|
|
if log.exception.is_a?(Semantic::TagWrapError) |
|
|
|
exc_wrapper = log.exception |
|
|
|
# puts "TAG_WRAP detected #{exc_wrapper.tag}" |
|
|
|
|
|
|
|
exc = exc_wrapper.error |
|
|
|
log.tags = Array.wrap(exc_wrapper.tag) |
|
|
|
else |
|
|
|
exc = log.exception |
|
|
|
end |
|
|
|
|
|
|
|
backtrace = exc.backtrace.select do |line| |
|
|
|
line.starts_with?(root_path) |
|
|
|
end |
|
|
|
|
|
|
|
if backtrace.count.positive? |
|
|
|
"-- #{ANSI_REVERSED_ERROR}#{log.exception.class}#{color_map.clear} #{color}#{log.exception.message}#{color_map.clear}#{SemanticLogger::AnsiColors::WHITE}\n\t#{backtrace.join("\n\t")}#{color_map.clear}\n\n" |
|
|
|
"-- #{ANSI_REVERSED_ERROR}#{exc.class}#{color_map.clear} #{color}#{exc.message}#{color_map.clear}#{SemanticLogger::AnsiColors::WHITE}\n\t#{backtrace.join("\n\t")}#{color_map.clear}\n\n" |
|
|
|
else |
|
|
|
"-- #{ANSI_REVERSED_ERROR}#{log.exception.class}: #{log.exception.message}#{color_map.clear}\n\n" |
|
|
|
"-- #{ANSI_REVERSED_ERROR}#{exc.class}: #{exc.message}#{color_map.clear}\n\n" |
|
|
|
end |
|
|
|
|
|
|
|
# TODO: remove me |
|
|
|
# clazz = colorize("#{exc.class}\n", color_map[:fatal]) |
|
|
|
# message = colorize(exc.message.chomp(''), color_map[:error]) |
|
|
|
|
|
|
|
# # TODO: backtrace_cleaner might be optionally disable from Live::Constant |
|
|
|
# backtrace = stackisize(Rails.backtrace_cleaner.clean(exc.backtrace)) |
|
|
|
|
|
|
|
# "#{clazz}#{message}#{backtrace}" |
|
|
|
end |
|
|
|
|
|
|
|
def call(log, logger) |
|
|
|