reidmorrison / rails_semantic_logger

Rails Semantic Logger replaces the Rails default logger with Semantic Logger
https://logger.rocketjob.io/rails
Apache License 2.0
320 stars 114 forks source link

fix: rack server deprecated in rack 3 #201

Closed nickstanish closed 9 months ago

nickstanish commented 10 months ago

Issue # (if available)

Closes #198

Description of changes

Clones Rack::Server monkeypatch to Rackup::Server

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

reidmorrison commented 9 months ago

Thank you for the pull request.

alexmalus commented 9 months ago

Hy @nickstanish :wave:, from the master branch, I tried running the tests locally for Rails 7.1, Ruby 3.2.2, still seeing the deprecation message.

appraisal rails_7.1 rake

>> BUNDLE_GEMFILE=/project_path/rails_semantic_logger/gemfiles/rails_7.1.gemfile bundle exec rake
/path/.rbenv/versions/3.2.2/bin/ruby -I"lib" /path/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb "test/action_controller_test.rb" "test/action_mailer_test.rb" "test/active_job_test.rb" "test/active_record_test.rb" "test/controllers/articles_controller_test.rb" "test/controllers/dashboard_controller_test.rb" "test/controllers/welcome_controller_test.rb" "test/rails_test.rb" 
Rack::Server is deprecated and replaced by Rackup::Server

I'm not seeing the message in my Rails project when I boot up the web server. Am in the dark about what's causing it to be displayed during test runs of this gem.

nickstanish commented 9 months ago

Hey @alexmalus

I wasn't seeing the message anymore in my Rails project either. Though I was able to reproduce that message locally by updating the gemfiles/rails_7.1.gemfile to require rack 3:

# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "puma"
gem "active_model_serializers"
gem "amazing_print"
gem "minitest"
gem "minitest-rails"
gem "rackup"
gem "rake"
gem "sprockets", "< 4.0"
gem "rails", "~> 7.1.0"
gem "sqlite3", "~> 1.4.0", platform: :ruby
gem "rubocop"

gemspec path: "../"
$ appraisal rails_7.1 rake
>> BUNDLE_GEMFILE=/Users/nick/Workspaces/other/rails_semantic_logger/gemfiles/rails_7.1.gemfile bundle exec rake
/Users/nick/.asdf/installs/ruby/3.2.2/bin/ruby -I"lib" /Users/nick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb "test/action_controller_test.rb" "test/action_mailer_test.rb" "test/active_job_test.rb" "test/active_record_test.rb" "test/controllers/articles_controller_test.rb" "test/controllers/dashboard_controller_test.rb" "test/controllers/welcome_controller_test.rb" "test/rails_test.rb"
Rack::Server is deprecated and replaced by Rackup::Server
DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.

I think that what's happening is Rack is used elsewhere in the repository, so that module is loaded and defined, but Rackup isn't so it falls into the latter branch. Including rackup in the gemfile so it's loaded by bundler forces this into the correct branch, but I'm not sure if that's an appropriate fix or not.

gem "rack", "~> 3.0"
+ gem "rackup"
gem "rake"
>> BUNDLE_GEMFILE=/Users/nick/Workspaces/other/rails_semantic_logger/gemfiles/rails_7.1.gemfile bundle exec rake
/Users/nick/.asdf/installs/ruby/3.2.2/bin/ruby -I"lib" /Users/nick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb "test/action_controller_test.rb" "test/action_mailer_test.rb" "test/active_job_test.rb" "test/active_record_test.rb" "test/controllers/articles_controller_test.rb" "test/controllers/dashboard_controller_test.rb" "test/controllers/welcome_controller_test.rb" "test/rails_test.rb"
DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.

Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
 (called from <top (required)> at /Users/nick/Workspaces/other/rails_semantic_logger/test/dummy/config/environment.rb:5)
Run options: --seed 3016