From 1a5b8bb1b515303e1095d05643167e40017fc345 Mon Sep 17 00:00:00 2001 From: pvincent Date: Thu, 13 Jun 2024 21:49:24 +0400 Subject: [PATCH] rendered --- lib/formatters/ansi_common.rb | 6 +++--- lib/formatters/ansi_formatter.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/formatters/ansi_common.rb b/lib/formatters/ansi_common.rb index f72b649..dcf03c5 100644 --- a/lib/formatters/ansi_common.rb +++ b/lib/formatters/ansi_common.rb @@ -2,11 +2,11 @@ require_relative 'ansi_colors' # gather common definitions and functions class AnsiCommon - def self.ansi_trace(trace) - match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*')/) # only m2(=file) and m4(=optional function) are useful + def self.ansi_trace(trace, symbol) + match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*'?)/) # only m2(=file) and m4(=optional function) are useful return trace unless match _, m2, _, m4 = match.captures - "➟ #{m2} #{AnsiColors::BOLD}#{m4.chop}#{AnsiColors::CLEAR}" + "#{symbol} #{m2} #{AnsiColors::BOLD}#{m4.chop}#{AnsiColors::CLEAR}" end end diff --git a/lib/formatters/ansi_formatter.rb b/lib/formatters/ansi_formatter.rb index ec08c83..226803b 100644 --- a/lib/formatters/ansi_formatter.rb +++ b/lib/formatters/ansi_formatter.rb @@ -119,14 +119,14 @@ class AnsiFormatter < SemanticLogger::Formatters::Color log.level = :debug log.message.lstrip! if log.name == 'ActiveRecord::Base' && log.message.starts_with?('↳ ') - log.message = AnsiCommon.ansi_trace(log.message) + 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}" + log.message = "⇤ Rendered#{m1} app/views/#{m2}#{m3}#{duration}" end end @@ -148,7 +148,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color def stackisize(items) return '' if items.empty? - traces = items.map { |item| AnsiCommon.ansi_trace(item) } + traces = items.map { |item| AnsiCommon.ansi_trace(item, '➟') } "\n#{traces.join("\n")}" end