Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly require rack/common_logger if :Verbose is true #2547

Merged

Conversation

wildmaples
Copy link
Contributor

@wildmaples wildmaples commented Feb 3, 2021

Description

Hello!

I found an issue where I had to require 'rack' or more specifically, 'rack/common_logger' when verbose is set to true, :Verbose => true.

Take this example:

require 'rack/handler/puma'

app = -> environment {[200, {}, []]}
Rack::Handler::Puma.run(app, :Verbose => true)

This is the exception:

Traceback (most recent call last):
       10: from /usr/bin/irb:23:in `<main>'
        9: from /usr/bin/irb:23:in `load'
        8: from /Library/Ruby/Gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        7: from (irb):3
        6: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/rack/handler/puma.rb:63:in `run'
        5: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/rack/handler/puma.rb:32:in `config'
        4: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/rack/handler/puma.rb:32:in `new'
        3: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/puma/configuration.rb:154:in `initialize'
        2: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/puma/configuration.rb:161:in `configure'
        1: from /Users/mapleong/.gem/ruby/2.6.0/gems/puma-5.2.0/lib/rack/handler/puma.rb:34:in `block in config'
NameError (uninitialized constant Rack::CommonLogger)

Users shouldn't have to require rack/common_logger on their end so I added a require "rack/common_logger" in the block where Verbose is true.

Questions:

  • Do you agree with this change? If so,
    • What is the best way to test this? I didn't find a good place to test it in test_rack_handler.rb
    • Should I add this change to the changelog / History.md?

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added an entry to History.md if this PR fixes a bug or adds a feature. If it doesn't need an entry to HISTORY.md, I have added [changelog skip] or [ci skip] to the pull request title.
  • I have added appropriate tests if this PR fixes a bug or adds a feature. (pending question)
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop. (pending)

@wildmaples wildmaples force-pushed the require-common-logger-if-verbose branch from 54d44f1 to 9ab1229 Compare February 3, 2021 20:35
@nateberkopec
Copy link
Member

Makes sense to me, thanks for the catch 👍

@nateberkopec nateberkopec merged commit 29bf4ac into puma:master Feb 3, 2021
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this pull request Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants