Sha256: 2814f40e72fcf2e154b7df24ff897bf1cc5304df83f3d3ab750f67bf8cc1489a

Contents?: true

Size: 614 Bytes

Versions: 19

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"
require "fiber"

module ActiveSupport
  module LoggerThreadSafeLevel # :nodoc:
    extend ActiveSupport::Concern

    def after_initialize
      @local_levels = Concurrent::Map.new(initial_capacity: 2)
    end

    def local_log_id
      Fiber.current.__id__
    end

    def local_level
      @local_levels[local_log_id]
    end

    def local_level=(level)
      if level
        @local_levels[local_log_id] = level
      else
        @local_levels.delete(local_log_id)
      end
    end

    def level
      local_level || super
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
activesupport-5.2.8.1 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.8 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.7.1 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.7 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.6.3 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.6.2 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.6.1 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.6 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.6 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.5 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.5 lib/active_support/logger_thread_safe_level.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.4 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.3 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.2 lib/active_support/logger_thread_safe_level.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.1 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4 lib/active_support/logger_thread_safe_level.rb
activesupport-5.2.4.rc1 lib/active_support/logger_thread_safe_level.rb