Sha256: 7aba7f6144852f0279cd0b759a0156da2705c1e75baed1d708845080615fee6c

Contents?: true

Size: 582 Bytes

Versions: 1

Compression:

Stored size: 582 Bytes

Contents

require 'active_support/concern'
require 'concurrent'

module ActiveSupport
  module LoggerThreadSafeLevel
    extend ActiveSupport::Concern

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

    def local_log_id
      Thread.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

1 entries across 1 versions & 1 rubygems

Version Path
activesupport-4.2.7.rc1 lib/active_support/logger_thread_safe_level.rb