aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/log_subscriber.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb
index 2e423b0364..720954625a 100644
--- a/activesupport/lib/active_support/log_subscriber.rb
+++ b/activesupport/lib/active_support/log_subscriber.rb
@@ -48,14 +48,14 @@ module ActiveSupport
mattr_accessor :colorize_logging
self.colorize_logging = true
- class_attribute :logger
-
class << self
- remove_method :logger
def logger
@logger ||= Rails.logger if defined?(Rails)
+ @logger
end
+ attr_writer :logger
+
def attach_to(namespace, log_subscriber=new, notifier=ActiveSupport::Notifications)
log_subscribers << log_subscriber
@@flushable_loggers = nil
@@ -87,27 +87,29 @@ module ActiveSupport
end
def initialize
- @event_stack = Hash.new { |h,id|
- h[id] = Hash.new { |ids,name| ids[name] = [] }
- }
+ @event_stack = []
super
end
+ def logger
+ LogSubscriber.logger
+ end
+
def start(name, id, payload)
return unless logger
e = ActiveSupport::Notifications::Event.new(name, Time.now, nil, id, payload)
- parent = @event_stack[id][name].last
+ parent = @event_stack.last
parent << e if parent
- @event_stack[id][name].push e
+ @event_stack.push e
end
def finish(name, id, payload)
return unless logger
finished = Time.now
- event = @event_stack[id][name].pop
+ event = @event_stack.pop
event.end = finished
method = name.split('.').first