From a1ae4651ffec02e24d902430ef157e7bfcfdf463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 15 Apr 2024 15:05:46 +0200 Subject: [PATCH] Simplify the way to set the maximum log size We can use the new configuration option in Rails 7.1, so we don't have to configure it manually. --- config/environments/development.rb | 6 ------ config/environments/test.rb | 6 ------ config/initializers/new_framework_defaults_7_1.rb | 6 +++--- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 4cc59fe36..274f0879f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -76,12 +76,6 @@ Rails.application.configure do config.eager_load_paths << "#{Rails.root}/spec/mailers/previews" config.action_mailer.preview_paths << "#{Rails.root}/spec/mailers/previews" - # Limit size of local logs - # TODO: replace with config.log_file_size after upgrading to Rails 7.1 - logger = ActiveSupport::Logger.new(config.default_log_file, 1, 100.megabytes) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 46a325320..adf9b6a18 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -67,12 +67,6 @@ Rails.application.configure do # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Limit size of local logs - # TODO: replace with config.log_file_size after upgrading to Rails 7.1 - logger = ActiveSupport::Logger.new(config.default_log_file, 1, 100.megabytes) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - # Raise error when a before_action's only/except options reference missing actions # config.action_controller.raise_on_missing_callback_actions = true diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index 7ac88e74f..b88647b52 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -149,9 +149,9 @@ Rails.application.config.active_support.use_message_serializer_for_metadata = tr # `config.load_defaults 7.1` does not set this value for environments other than # development and test. #++ -# if Rails.env.local? -# Rails.application.config.log_file_size = 100 * 1024 * 1024 -# end +if Rails.env.local? + Rails.application.config.log_file_size = 100 * 1024 * 1024 +end ### # Enable raising on assignment to attr_readonly attributes. The previous