Sha256: 4fcd6e16ef49421833115c92fd1a58c6a24dac2fbc62013aac47037ddf2cc63a
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require "active_support/concern" require "active_support/core_ext/module/attribute_accessors" require "concurrent" require "fiber" module ActiveSupport module LoggerThreadSafeLevel # :nodoc: extend ActiveSupport::Concern Logger::Severity.constants.each do |severity| class_eval(<<-EOT, __FILE__, __LINE__ + 1) def #{severity.downcase}? # def debug? Logger::#{severity} >= level # DEBUG >= level end # end EOT end def local_level IsolatedExecutionState[local_level_key] end def local_level=(level) case level when Integer when Symbol level = Logger::Severity.const_get(level.to_s.upcase) when nil else raise ArgumentError, "Invalid log level: #{level.inspect}" end if level.nil? IsolatedExecutionState.delete(local_level_key) else IsolatedExecutionState[local_level_key] = level end end def level local_level || super end # Change the thread-local level for the duration of the given block. def log_at(level) old_local_level, self.local_level = local_level, level yield ensure self.local_level = old_local_level end private def local_level_key @local_level_key ||= :"logger_thread_safe_level_#{object_id}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activesupport-7.1.0.beta1 | lib/active_support/logger_thread_safe_level.rb |