Module: ActiveSupport::LoggerThreadSafeLevel

Extended by:
Concern
Defined in:
lib/activesupport/logger_thread_safe_level.rb

Overview

Instance Method Summary collapse

Instance Method Details

#levelObject



31
32
33
# File 'lib/activesupport/logger_thread_safe_level.rb', line 31

def level
  local_level || super
end

#local_levelObject



11
12
13
# File 'lib/activesupport/logger_thread_safe_level.rb', line 11

def local_level
  IsolatedExecutionState[local_level_key]
end

#local_level=(level) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/activesupport/logger_thread_safe_level.rb', line 15

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

#log_at(level) ⇒ Object

Change the thread-local level for the duration of the given block.



36
37
38
39
40
41
# File 'lib/activesupport/logger_thread_safe_level.rb', line 36

def log_at(level)
  old_local_level, self.local_level = local_level, level
  yield
ensure
  self.local_level = old_local_level
end