blob: 5fedb5e6898be6c3308f6e37ce4d9df06be6a59c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
require 'active_support/concern'
module ActiveSupport
module LoggerThreadSafeLevel # :nodoc:
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
|