lib/semantic_logger/logger.rb in semantic_logger-4.6.1 vs lib/semantic_logger/logger.rb in semantic_logger-4.7.0

- old
+ new

@@ -1,17 +1,17 @@ -require 'concurrent' +require "concurrent" module SemanticLogger # Logger stores the class name to be used for all log messages so that every # log message written by this instance will include the class name class Logger < Base include SemanticLogger::Concerns::Compatibility def self.subscribe(object = nil, &block) subscriber = block || object unless subscriber.is_a?(Proc) || subscriber.respond_to?(:call) - raise('When supplying an on_log subscriber, it must support the #call method') + raise("When supplying an on_log subscriber, it must support the #call method") end subscribers = (@subscribers ||= Concurrent::Array.new) subscribers << subscriber unless subscribers.include?(subscriber) end @@ -19,11 +19,11 @@ class << self attr_reader :subscribers end def self.processor - @processor + @processor ||= SemanticLogger.sync? ? SyncProcessor.new : Processor.new end # Returns a Logger instance # # Return the logger for a specific class, supports class specific log levels @@ -63,20 +63,20 @@ Logger.processor.log(log) end private - @processor = Processor.new + @processor = nil @subscribers = nil def self.call_subscribers(log) return unless @subscribers @subscribers.each do |subscriber| begin subscriber.call(log) - rescue Exception => exc - self.class.processor.logger.error('Exception calling :on_log subscriber', exc) + rescue Exception => e + self.class.processor.logger.error("Exception calling :on_log subscriber", e) end end end end end