Skip to content

Commit

Permalink
Fix error backtrace debug logging && Do not log request dump if it is…
Browse files Browse the repository at this point in the history
… not parsed (#2376)
  • Loading branch information
alexeevit committed Sep 22, 2020
1 parent 7928173 commit a734909
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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

0 comments on commit a734909

Please sign in to comment.