Skip to content

Commit

Permalink
Prefer Rails.logger over RAILS_DEFAULT_LOGGER
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 11, 2008
1 parent 455c7f9 commit 75fa824
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/failsafe.rb
Expand Up @@ -42,8 +42,8 @@ def log_failsafe_exception(exception)
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
Expand Down
6 changes: 3 additions & 3 deletions activesupport/lib/active_support/dependencies.rb
Expand Up @@ -559,9 +559,9 @@ class LoadingModule #: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
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/deprecation.rb
Expand Up @@ -13,7 +13,7 @@ module Deprecation #:nodoc:
$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
}
Expand Down
4 changes: 3 additions & 1 deletion railties/lib/commands/runner.rb
Expand Up @@ -48,5 +48,7 @@
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

0 comments on commit 75fa824

Please sign in to comment.