Deprecate different default for log_level
in production
This is a more conservative approach to 2602a49. Also changed the comment to be more inline with everything else in the file (describing what the config value is doing and why). People should just read the docs for alternatives.
This commit is contained in:
parent
402cc9f46a
commit
a6de6f508c
@ -1,5 +1,6 @@
|
||||
require "active_support/notifications"
|
||||
require "active_support/dependencies"
|
||||
require "active_support/deprecation"
|
||||
require "active_support/descendants_tracker"
|
||||
|
||||
module Rails
|
||||
@ -54,6 +55,18 @@ module Bootstrap
|
||||
logger
|
||||
end
|
||||
|
||||
if Rails.env.production? && !config.has_explicit_log_level?
|
||||
ActiveSupport::Deprecation.warn \
|
||||
"You did not specify a `log_level` in `production.rb`. Currently, " \
|
||||
"the default value for `log_leve` is `:info` for the production " \
|
||||
"environment and `:debug` in all other environments. In Rails 5 " \
|
||||
"the default value will be unified to `:debug` across all " \
|
||||
"environments. To preserve the current setting, add the following " \
|
||||
"line to your `production.rb`:\n" \
|
||||
"\n" \
|
||||
" config.log_level = :info\n\n"
|
||||
end
|
||||
|
||||
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,6 @@ class Configuration < ::Rails::Engine::Configuration
|
||||
:time_zone, :reload_classes_only_on_change,
|
||||
:beginning_of_week, :filter_redirect, :x
|
||||
|
||||
attr_writer :log_level
|
||||
attr_reader :encoding
|
||||
|
||||
def initialize(*)
|
||||
@ -34,6 +33,7 @@ def initialize(*)
|
||||
@session_options = {}
|
||||
@time_zone = "UTC"
|
||||
@beginning_of_week = :monday
|
||||
@has_explicit_log_level = false
|
||||
@log_level = nil
|
||||
@middleware = app_middleware
|
||||
@generators = app_generators
|
||||
@ -117,8 +117,17 @@ def database_configuration
|
||||
raise e, "Cannot load `Rails.application.database_configuration`:\n#{e.message}", e.backtrace
|
||||
end
|
||||
|
||||
def has_explicit_log_level? # :nodoc:
|
||||
@has_explicit_log_level
|
||||
end
|
||||
|
||||
def log_level=(level)
|
||||
@has_explicit_log_level = !!(level)
|
||||
@log_level = level
|
||||
end
|
||||
|
||||
def log_level
|
||||
@log_level ||= Rails.env.production? ? :info : :debug
|
||||
@log_level ||= (Rails.env.production? ? :info : :debug)
|
||||
end
|
||||
|
||||
def colorize_logging
|
||||
|
@ -45,7 +45,8 @@ Rails.application.configure do
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Set to :info to decrease the log volume.
|
||||
# Use the lowest log_level to ensure availability of diagnostic information
|
||||
# when problems arise.
|
||||
config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
|
Loading…
Reference in New Issue
Block a user