Browse Source

monkey_patch SemanticLogger::Appenders

main
pvincent 2 months ago
parent
commit
d8b5387aa1
  1. 3
      app/controllers/hot_controller.rb
  2. 19
      lib/monkey_patches/semantic_logger/appenders.rb

3
app/controllers/hot_controller.rb

@ -4,5 +4,8 @@ class HotController < ApplicationController
logger.info('callee') logger.info('callee')
logger.info(__callee__) logger.info(__callee__)
logger.info(__method__) logger.info(__method__)
# logger.info(ActiveSupport::LogSubscriber.subscribers.map(&:patterns))
logger.info(ActiveSupport::Notifications.notifier.listeners_for('.*\.action_controller'))
end end
end end

19
lib/monkey_patches/semantic_logger/appenders.rb

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