Module: ActiveSupport::LoggerThreadSafeLevel
Do not use. This module is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Concern
|
|
Defined in: | activesupport/lib/active_support/logger_thread_safe_level.rb |
Class Method Summary
Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
append_features, prepend_features |
Instance Attribute Summary
- #local_level rw
- #local_level=(level) rw
- #local_level_key readonly private
Instance Method Summary
- #initialize
- #level
-
#log_at(level)
Change the thread-local level for the duration of the given block.
Instance Attribute Details
#local_level (rw)
[ GitHub ]# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 15
def local_level IsolatedExecutionState[local_level_key] end
#local_level=(level) (rw)
[ GitHub ]# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 19
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
#local_level_key (readonly, private)
[ GitHub ]# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 48
attr_reader :local_level_key
Instance Method Details
#initialize
[ GitHub ]# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 10
def initialize(...) super @local_level_key = :"logger_thread_safe_level_#{object_id}" end
#level
[ GitHub ]# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 35
def level local_level || super end
#log_at(level)
Change the thread-local level for the duration of the given block.
# File 'activesupport/lib/active_support/logger_thread_safe_level.rb', line 40
def log_at(level) old_local_level, self.local_level = local_level, level yield ensure self.local_level = old_local_level end