lib/semantic_logger/logger.rb in semantic_logger-4.7.4 vs lib/semantic_logger/logger.rb in semantic_logger-4.8.0

- old
+ new

@@ -19,13 +19,25 @@ class << self attr_reader :subscribers end def self.processor - @processor ||= SemanticLogger.sync? ? SyncProcessor.new : Processor.new + @processor ||= Processor.new end + # Switch to the synchronous processor + def self.sync! + return if @processor.is_a?(SyncProcessor) + + @processor = SyncProcessor.new(@processor&.appenders) + end + + # Running without the background logging thread? + def self.sync? + processor.is_a?(SyncProcessor) + end + # Returns a Logger instance # # Return the logger for a specific class, supports class specific log levels # logger = SemanticLogger::Logger.new(self) # OR @@ -68,14 +80,12 @@ def self.call_subscribers(log) return unless @subscribers @subscribers.each do |subscriber| - begin - subscriber.call(log) - rescue Exception => e - processor.logger.error("Exception calling :on_log subscriber", e) - end + subscriber.call(log) + rescue Exception => e + processor.logger.error("Exception calling :on_log subscriber", e) end end end end