|
@ -95,7 +95,19 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
def build_terminus = "#{origin} #{TERMINUS_STRING} " |
|
|
def build_terminus = "#{origin} #{TERMINUS_STRING} " |
|
|
def centerize(text) = text.truncate(CENTER_SIZE).center(CENTER_SIZE) |
|
|
def centerize(text) = text.truncate(CENTER_SIZE).center(CENTER_SIZE) |
|
|
def colorize(text, tint = color) = "#{tint}#{text}#{CLEAR}" |
|
|
def colorize(text, tint = color) = "#{tint}#{text}#{CLEAR}" |
|
|
def stackisize(items) = items.length.positive? ? "\n#{items.join("\n")}" : '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stackisize(items) |
|
|
|
|
|
return '' if items.empty? |
|
|
|
|
|
|
|
|
|
|
|
traces = items.map do |item| |
|
|
|
|
|
trace = item.match(/(.*:\d+):in `(.*)'/) |
|
|
|
|
|
next item unless trace |
|
|
|
|
|
|
|
|
|
|
|
m1, m2 = trace.captures |
|
|
|
|
|
"↳ #{m1} #{AnsiColors::BOLD}#{m2}#{AnsiColors::CLEAR}" |
|
|
|
|
|
end |
|
|
|
|
|
"\n#{traces.join("\n")}" |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
def build_dimensions(dimensions) |
|
|
def build_dimensions(dimensions) |
|
|
"#{origin} #{dimensions.rails} " |
|
|
"#{origin} #{dimensions.rails} " |
|
@ -117,17 +129,11 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
exc = log.exception |
|
|
exc = log.exception |
|
|
clazz = colorize("#{exc.class}\n", color_map[:fatal]) |
|
|
clazz = colorize("#{exc.class}\n", color_map[:fatal]) |
|
|
message = colorize(exc.message.chomp(''), color_map[:error]) |
|
|
message = colorize(exc.message.chomp(''), color_map[:error]) |
|
|
backtrace = stackisize(clean_backtrace(exc.backtrace)) |
|
|
|
|
|
|
|
|
backtrace = stackisize(Rails.backtrace_cleaner.clean(exc.backtrace)) |
|
|
|
|
|
|
|
|
"#{clazz}#{message}#{backtrace}" |
|
|
"#{clazz}#{message}#{backtrace}" |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def clean_backtrace(backtrace) |
|
|
|
|
|
root_path = Rails.root.to_s |
|
|
|
|
|
backtrace = backtrace.select { |line| line.starts_with?(root_path) } |
|
|
|
|
|
backtrace.map { |line| line.delete_prefix("#{root_path}/") } |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def level_char |
|
|
def level_char |
|
|
case log.level |
|
|
case log.level |
|
|
when :info, :debug then ' ' |
|
|
when :info, :debug then ' ' |
|
|