|
|
@ -16,6 +16,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
|
FAILOVER_WRAP = 80 |
|
|
|
CHAR_FATAL = '⯶'.freeze |
|
|
|
TERMINUS_STRING = '╙─╜'.freeze |
|
|
|
RENDERED_VIEW_DURATION = 100 |
|
|
|
|
|
|
|
def initialize |
|
|
|
super(color_map: |
|
|
@ -101,9 +102,18 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
|
log.message.lstrip! |
|
|
|
if log.name == 'ActiveRecord::Base' && log.message.starts_with?('↳ ') |
|
|
|
log.message = AnsiCommon.ansi_trace(log.message) |
|
|
|
elsif log.name == 'ActionView::Base' |
|
|
|
match = log.message.match(/^Rendered( layout| collection of|) (.*?\.erb)(.*)(\(Duration:.*\))/) |
|
|
|
if match |
|
|
|
m1, m2, m3, m4 = match.captures |
|
|
|
duration = m4.match(/Duration: (\d+\.?\d*)ms/).match(1).to_f |
|
|
|
duration = duration < RENDERED_VIEW_DURATION ? '' : m4.to_s |
|
|
|
log.message = "Rendered#{m1} #{m2}#{m3}#{duration}" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
log |
|
|
|
end |
|
|
|
|
|
|
|