Prefer Rails.logger over RAILS_DEFAULT_LOGGER

This commit is contained in:
Joshua Peek
2008-12-10 18:07:02 -06:00
parent 455c7f9e37
commit 75fa82418d
4 changed files with 9 additions and 7 deletions

View File

@@ -42,8 +42,8 @@ module ActionController
end
def failsafe_logger
if defined?(::RAILS_DEFAULT_LOGGER) && !::RAILS_DEFAULT_LOGGER.nil?
::RAILS_DEFAULT_LOGGER
if defined? Rails && Rails.logger
Rails.logger
else
Logger.new($stderr)
end

View File

@@ -559,9 +559,9 @@ module ActiveSupport #:nodoc:
# Old style environment.rb referenced this method directly. Please note, it doesn't
# actually *do* anything any more.
def self.root(*args)
if defined?(RAILS_DEFAULT_LOGGER)
RAILS_DEFAULT_LOGGER.warn "Your environment.rb uses the old syntax, it may not continue to work in future releases."
RAILS_DEFAULT_LOGGER.warn "For upgrade instructions please see: http://manuals.rubyonrails.com/read/book/19"
if defined? Rails && Rails.logger
Rails.logger.warn "Your environment.rb uses the old syntax, it may not continue to work in future releases."
Rails.logger.warn "For upgrade instructions please see: http://manuals.rubyonrails.com/read/book/19"
end
end
end

View File

@@ -13,7 +13,7 @@ module ActiveSupport
$stderr.puts callstack.join("\n ") if debug
},
'development' => Proc.new { |message, callstack|
logger = defined?(::RAILS_DEFAULT_LOGGER) ? ::RAILS_DEFAULT_LOGGER : Logger.new($stderr)
logger = defined? Rails ? Rails.logger : Logger.new($stderr)
logger.warn message
logger.debug callstack.join("\n ") if debug
}

View File

@@ -48,5 +48,7 @@ begin
eval(code_or_file)
end
ensure
RAILS_DEFAULT_LOGGER.flush if RAILS_DEFAULT_LOGGER
if defined? Rails
Rails.logger.flush if Rails.logger.respond_to?(:flush)
end
end