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

[changelog skip] Fix error backtrace debug logging && Don't log not parsed request #2376

Merged
merged 1 commit into from Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puma/error_logger.rb
Expand Up @@ -51,8 +51,8 @@ def debug(options={})

string_block = []
string_block << title(options)
string_block << request_dump(req) if req
string_block << error_backtrace(options) if error
string_block << request_dump(req) if request_parsed?(req)
string_block << error.backtrace if error

ioerr.puts string_block.join("\n")
end
Expand Down
17 changes: 17 additions & 0 deletions test/test_error_logger.rb
Expand Up @@ -59,6 +59,23 @@ def test_debug_with_debug_mode
end
end

def test_debug_backtrace_logging
with_debug_mode do
def dummy_error
raise StandardError.new('non-blank')
rescue => e
Puma::ErrorLogger.stdio.debug(error: e)
end

_, err = capture_io do
dummy_error
end

assert_match %r!non-blank!, err
assert_match %r!:in `dummy_error'!, err
end
end

private

def with_debug_mode
Expand Down