From 1f4a92b6d414e345871c22478d6c0581552a5786 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 4 Feb 2023 07:07:43 +0100 Subject: [PATCH] allow log levels to be configurable via ENV --- config/environments/development.rb | 6 +++++- config/environments/production.rb | 2 +- config/environments/test.rb | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 317e27e3..c2434c8c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -51,6 +51,10 @@ Rails.application.configure do config.action_mailer.perform_caching = false + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = ENV.fetch("LOG_LEVEL") { "debug" }.to_sym + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -73,6 +77,6 @@ Rails.application.configure do # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end -# For better_errors to work inside Docker we need +# For better_errors to work inside Docker we need # to allow 0.0.0.0 as an IP in development context BetterErrors::Middleware.allow_ip! "0.0.0.0/0" diff --git a/config/environments/production.rb b/config/environments/production.rb index 5964fe5c..3ae984d5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -45,7 +45,7 @@ Rails.application.configure do # Use the lowest log level to ensure availability of diagnostic information # when problems arise. - config.log_level = :debug + config.log_level = ENV.fetch("LOG_LEVEL") { "info" }.to_sym # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] diff --git a/config/environments/test.rb b/config/environments/test.rb index 30587ef6..036f3f7a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -34,6 +34,10 @@ Rails.application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = ENV.fetch("LOG_LEVEL") { "debug" }.to_sym + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr