Browse Source

tag_wrap_error building

main
pvincent 2 months ago
parent
commit
e39c73fe75
  1. 1
      app/controllers/scores_controller.rb
  2. 17
      lib/monkey_patches/semantic_logger.rb
  3. 8
      lib/monkey_patches/semantic_logger/appenders.rb
  4. 0
      lib/monkey_patches/semantic_logger/base.rb
  5. 3
      lib/semantic/ansi_formatter.rb
  6. 2
      lib/semantic/tag_wrap_error.rb

1
app/controllers/scores_controller.rb

@ -37,6 +37,7 @@ class ScoresController < ApplicationController
end end
def destroy def destroy
aazazaz
# @score.destroy! # @score.destroy!
# redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other # redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other

17
lib/monkey_patches/semantic_logger.rb

@ -0,0 +1,17 @@
module SemanticLogger
def self.fast_tag(tag)
return yield if tag.nil? || tag == ''
t = Thread.current[:semantic_logger_tags] ||= []
begin
t << tag
yield
# PVINCENT's addition
rescue StandardError => e
raise Semantic::TagWrapError.new(tag, e)
# END OF addition
ensure
t.pop
end
end
end

8
lib/monkey_patches/semantic_logger/appenders.rb

@ -1,17 +1,19 @@
module SemanticLogger module SemanticLogger
# Manage a collection of appenders.
class Appenders < Concurrent::Array class Appenders < Concurrent::Array
def close def close
closed_appenders = [] closed_appenders = []
each do |appender| each do |appender|
logger.trace "Closing appender: #{appender.name}" logger.trace "Closing appender: #{appender.name}"
closed_appenders << appender
# PVINCENT's change
closed_appenders << appender # closed_ missing!!!!
# END OF change
appender.flush appender.flush
appender.close appender.close
rescue Exception => e rescue Exception => e
logger.error "Failed to close appender: #{appender.name}", e logger.error "Failed to close appender: #{appender.name}", e
end end
# Delete appenders outside the #each above which prevents changes during iteration.
closed_appenders.each { |appender| delete(appender) } closed_appenders.each { |appender| delete(appender) }
logger.trace 'All appenders closed and removed from appender list' logger.trace 'All appenders closed and removed from appender list'
end end

0
lib/monkey_patches/rails_semantic_logger/base.rb → lib/monkey_patches/semantic_logger/base.rb

3
lib/semantic/ansi_formatter.rb

@ -29,7 +29,7 @@ module Semantic
end end
def call(log, logger) def call(log, logger)
# puts 'ok'
# puts 'ok2'
log = alter(log) log = alter(log)
self.log = log self.log = log
@ -167,6 +167,7 @@ module Semantic
if log.exception.is_a?(Semantic::TagWrapError) if log.exception.is_a?(Semantic::TagWrapError)
exc_wrapper = log.exception exc_wrapper = log.exception
# puts "TAG_WRAP detected #{exc_wrapper.tag}" # puts "TAG_WRAP detected #{exc_wrapper.tag}"
exc = exc_wrapper.error exc = exc_wrapper.error
log.tags = Array.wrap(exc_wrapper.tag) log.tags = Array.wrap(exc_wrapper.tag)
else else

2
lib/semantic/tag_wrap_error.rb

@ -9,6 +9,6 @@ module Semantic
super("my error message contains tag #{tag}") super("my error message contains tag #{tag}")
end end
def to_s = "TagWrap #{@tag}"
def to_s = "#{self.class}#{@tag}"
end end
end end
Loading…
Cancel
Save