Skip to content

Commit

Permalink
make logger a singleton on the class
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jun 19, 2012
1 parent c6af764 commit a6fd462
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions activesupport/lib/active_support/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class LogSubscriber
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
Expand Down Expand Up @@ -91,6 +91,10 @@ def initialize
super
end

def logger
LogSubscriber.logger
end

def start(name, id, payload)
return unless logger

Expand Down

0 comments on commit a6fd462

Please sign in to comment.