diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index dba92e0..959b1c6 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -5,7 +5,7 @@ class ScoresController < ApplicationController before_action :set_score, only: %i[show edit update destroy] def index - logger.info('inside controller22') + logger.info('inside controller2') @q = Score.all.ransack(q_params) @pagy, @scores = pagy(@q.result) end @@ -37,6 +37,8 @@ class ScoresController < ApplicationController end def destroy + zazaz + @score.destroy! redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other diff --git a/config/environments/development.rb b/config/environments/development.rb index 92a8945..c96236c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -78,6 +78,6 @@ Rails.application.configure do # rubocop:disable Metrics/BlockLength routes.default_url_options[:port] = ARGV[1] # ie: Procfile.dev --port PORT routes.default_url_options[:host] = '127.0.0.1' - # config.x.semantic.formatter = 'Semantic::BasicFormatter' config.x.semantic.formatter = 'Semantic::FancyFormatter' + config.x.semantic.formatter = 'Semantic::BasicFormatter' end diff --git a/lib/semantic/abstract_formatter.rb b/lib/semantic/abstract_formatter.rb new file mode 100644 index 0000000..710c01c --- /dev/null +++ b/lib/semantic/abstract_formatter.rb @@ -0,0 +1,5 @@ +module Semantic + # Abstract colorized formatter + class AbstractFormatter < SemanticLogger::Formatters::Color + end +end diff --git a/lib/semantic/basic_formatter.rb b/lib/semantic/basic_formatter.rb index c15ab67..17301c4 100644 --- a/lib/semantic/basic_formatter.rb +++ b/lib/semantic/basic_formatter.rb @@ -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) diff --git a/lib/semantic/fancy_formatter.rb b/lib/semantic/fancy_formatter.rb index 8165a49..3dfcece 100644 --- a/lib/semantic/fancy_formatter.rb +++ b/lib/semantic/fancy_formatter.rb @@ -4,7 +4,7 @@ require 'json' module Semantic # wraps meanwhile takes care of ansi colors - class FancyFormatter < SemanticLogger::Formatters::Color + class FancyFormatter < AbstractFormatter include AnsiColors TAG_NONE = ''.freeze @@ -180,7 +180,9 @@ module Semantic clazz = colorize("#{exc.class}\n", color_map[:fatal]) message = colorize(exc.message.chomp(''), color_map[:error]) - backtrace = stackisize(Rails.backtrace_cleaner.clean(exc.backtrace)) # TODO: backtrace_cleaner might be optionally disable from Live::Constant + + # TODO: backtrace_cleaner might be optionally disable from Live::Constant + backtrace = stackisize(Rails.backtrace_cleaner.clean(exc.backtrace)) "#{clazz}#{message}#{backtrace}" end