config.logger level is overwritten

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

config.logger level is overwritten

Morteza Milani
Hello all,

I have a comment about rails logger and I wish to change its behaviour.

Rails tries to load the logger from config like this:

Rails.logger ||= config.logger || begin
   
logger = ActiveSupport::Logger.new(config.default_log_file)
   
....
end

https://github.com/rails/rails/blob/fa986ae0cac423bf1ebcb5caeccbecf00c990094/railties/lib/rails/application/bootstrap.rb#L36

Then later after the above block, it sets the logger level:

Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)

https://github.com/rails/rails/blob/fa986ae0cac423bf1ebcb5caeccbecf00c990094/railties/lib/rails/application/bootstrap.rb#L53


The problem is that this overwrites the level that is set in the config.logger. In normal cases, it is no problem. But when different logging classes are embedded
and they depend on the log level, this makes a problem since the final value of the logger will be different from the value set in the config.logger.

Moreover, it is more intuitive to expect the logging level set on the object provided rather than config.log_level.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f21e6963-3ada-40a6-844d-19fb15172f4e%40googlegroups.com.