Permalink
Browse files

Only lookup `config.log_level` for stdlib `::Logger`. Closes #11665.

This prevents Rails from assigning meaningless log levels to third
party loggers like log4r. If `Rails.logger` is not `kind_of?(::Logger)`
we simply assign the `config.log_level` as is.

This bug was introduced by #11665.

Conflicts:
	railties/CHANGELOG.md
	railties/test/application/configuration_test.rb
  • Loading branch information...
1 parent 68cd3bc commit e2b2539468e2f0109ca309ed9ade53edbcc156a2 @senny senny committed Jan 13, 2014
View
@@ -1,3 +1,10 @@
+* Only lookup `config.log_level` for stdlib `::Logger` instances.
+ Assign it as is for third party loggers like `Log4r::Logger`.
+
+ Fixes #13421.
+
+ *Yves Senn*
+
* Add `ENV['DATABASE_URL']` support in `rails dbconsole`. Fixes #13320.
*Huiming Teo*
@@ -53,7 +53,11 @@ module Bootstrap
logger
end
- Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
+ if ::Logger === Rails.logger
+ Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
+ else
+ Rails.logger.level = config.log_level
+ end
end
# Initialize cache early in the stack so railties can make use of it.
@@ -672,12 +672,25 @@ def index
end
end
- test "config.log_level with custom logger" do
+ test "lookup config.log_level with custom logger (stdlib Logger)" do
make_basic_app do |app|
app.config.logger = Logger.new(STDOUT)
app.config.log_level = :info
end
assert_equal Logger::INFO, Rails.logger.level
end
+
+ test "assign log_level as is with custom logger (third party logger)" do
+ logger_class = Class.new do
+ attr_accessor :level
+ end
+ logger_instance = logger_class.new
+ make_basic_app do |app|
+ app.config.logger = logger_instance
+ app.config.log_level = :info
+ end
+ assert_equal logger_instance, Rails.logger
+ assert_equal :info, Rails.logger.level
+ end
end
end

0 comments on commit e2b2539

Please sign in to comment.