aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-12 12:52:09 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-13 01:19:22 +0100
commit5f34bd61b0a49478ddf6a9a69654b8e56f0f20d3 (patch)
tree6438af76aefbe373efc331d3ee8e50770b43cc04
parentc4e3344a26dce5d2bc15e788c75140356a40537c (diff)
downloadrails-5f34bd61b0a49478ddf6a9a69654b8e56f0f20d3.tar.gz
rails-5f34bd61b0a49478ddf6a9a69654b8e56f0f20d3.tar.bz2
rails-5f34bd61b0a49478ddf6a9a69654b8e56f0f20d3.zip
As the other constants, RAILS_DEFAULT_LOGGER no more.
-rw-r--r--railties/lib/rails.rb21
-rw-r--r--railties/lib/rails/bootstrap.rb35
2 files changed, 23 insertions, 33 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb
index c21434a100..5f7e595d64 100644
--- a/railties/lib/rails.rb
+++ b/railties/lib/rails.rb
@@ -32,11 +32,6 @@ end
module Rails
autoload :Bootstrap, 'rails/bootstrap'
- # Needs to be duplicated from Active Support since its needed before Active
- # Support is available. Here both Options and Hash are namespaced to prevent
- # conflicts with other implementations AND with the classes residing in Active Support.
- # ---
- # TODO: w0t?
class << self
def application
@@application ||= nil
@@ -48,7 +43,7 @@ module Rails
# The Configuration instance used to configure the Rails environment
def configuration
- application.configuration
+ application.config
end
def initialize!
@@ -56,19 +51,19 @@ module Rails
end
def initialized?
- @initialized || false
+ @@initialized || false
end
def initialized=(initialized)
- @initialized ||= initialized
+ @@initialized ||= initialized
end
def logger
- if defined?(RAILS_DEFAULT_LOGGER)
- RAILS_DEFAULT_LOGGER
- else
- nil
- end
+ @@logger ||= nil
+ end
+
+ def logger=(logger)
+ @@logger = logger
end
def backtrace_cleaner
diff --git a/railties/lib/rails/bootstrap.rb b/railties/lib/rails/bootstrap.rb
index 3808695f10..99a5ddeb8a 100644
--- a/railties/lib/rails/bootstrap.rb
+++ b/railties/lib/rails/bootstrap.rb
@@ -69,28 +69,23 @@ module Rails
end
initializer :initialize_logger do
- # if the environment has explicitly defined a logger, use it
- next if Rails.logger
-
- unless logger = config.logger
- begin
- logger = ActiveSupport::BufferedLogger.new(config.log_path)
- logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
- if Rails.env.production?
- logger.auto_flushing = false
- end
- rescue StandardError => e
- logger = ActiveSupport::BufferedLogger.new(STDERR)
- logger.level = ActiveSupport::BufferedLogger::WARN
- logger.warn(
- "Rails Error: Unable to access log file. Please ensure that #{config.log_path} exists and is chmod 0666. " +
- "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
- )
- end
+ Rails.logger ||= config.logger || begin
+ logger = ActiveSupport::BufferedLogger.new(config.log_path)
+ logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
+ logger.auto_flushing = false if Rails.env.production?
+ logger
+ rescue StandardError => e
+ logger = ActiveSupport::BufferedLogger.new(STDERR)
+ logger.level = ActiveSupport::BufferedLogger::WARN
+ logger.warn(
+ "Rails Error: Unable to access log file. Please ensure that #{config.log_path} exists and is chmod 0666. " +
+ "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
+ )
+ logger
end
- # TODO: Why are we silencing warning here?
- silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger }
+ # TODO: Wrap it in a deprecation proxy
+ silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", Rails.logger }
end
# Sets the logger for Active Record, Action Controller, and Action Mailer