diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/log_subscriber.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index 8c3921c423..384c56cd5a 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -87,7 +87,7 @@ module ActiveSupport end def initialize - @event_stack = [] + @queue_key = [self.class.name, object_id].join "-" super end @@ -99,17 +99,17 @@ module ActiveSupport return unless logger e = ActiveSupport::Notifications::Event.new(name, Time.now, nil, id, payload) - parent = @event_stack.last + parent = event_stack.last parent << e if parent - @event_stack.push e + event_stack.push e end def finish(name, id, payload) return unless logger finished = Time.now - event = @event_stack.pop + event = event_stack.pop event.end = finished event.payload.merge!(payload) @@ -142,5 +142,11 @@ module ActiveSupport bold = bold ? BOLD : "" "#{bold}#{color}#{text}#{CLEAR}" end + + private + + def event_stack + Thread.current[@queue_key] ||= [] + end end end |