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

Clean up traceback printing in arbitar #1201

Merged
merged 1 commit into from Feb 9, 2016

Conversation

Projects
None yet
2 participants
@bloodearnest
Contributor

bloodearnest commented Feb 9, 2016

Currently, on some errors, tracebacks are manually included in the log message. This patch instead uses the stdlibs logging traceback printing. This allow better log customisation and control.

Additionally, because the call to logging.exception included the traceback in its log message, the traceback was printed twice the logs, as logging.exception always prints the traceback.

I've left the exceptions logged at debug/info as they are, but it seems to me they'd be better off as error level, since we sys.exit() after both anyway,

@benoitc

This comment has been minimized.

Show comment
Hide comment
@benoitc

benoitc Feb 9, 2016

Owner

👍 can you rebase the commits in 1 ? will merge it right after.

Owner

benoitc commented Feb 9, 2016

👍 can you rebase the commits in 1 ? will merge it right after.

Let logging module handle traceback printing
Manually including the traceback in the log msg causes some issues when
interacting with log formats, and in one case was causing the traceback
to be printed twice.
@bloodearnest

This comment has been minimized.

Show comment
Hide comment
@bloodearnest

bloodearnest Feb 9, 2016

Contributor

Done, thanks

Contributor

bloodearnest commented Feb 9, 2016

Done, thanks

benoitc added a commit that referenced this pull request Feb 9, 2016

Merge pull request #1201 from bloodearnest/double_exc
Clean up traceback printing in arbitar

@benoitc benoitc merged commit a3e3ee8 into benoitc:master Feb 9, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@benoitc

This comment has been minimized.

Show comment
Hide comment
@benoitc

benoitc Feb 9, 2016

Owner

thanks!

Owner

benoitc commented Feb 9, 2016

thanks!

wking added a commit to wking/gunicorn that referenced this pull request Nov 3, 2017

gunicorn: Use exc_info liberally
The argument is documented in [1], and we've been using it in some
cases since 410bcfa (Fix statsd logging to work on Python 3,
2015-04-20, #1010).  This commit goes through all of our log calls and
makes sure we're using it consistently.

For more examples of using exc_info instead of direct traceback calls,
see 0acfb55 (Let logging module handle traceback printing,
2016-02-05, #1201).  The traceback call I'm removing snuck in later
with f4842a5 (Log exception occurring during worker exit, 2016-05-04,
#1254).

I'm removing the "Error processing SSL request" debug messages,
because those will be handled by the subsequent handle_error call.
We've had them, for reasons that I'm not clear on, since 1198cc2
(handle ssl connections, 2012-12-14).

I've restored logging in the URI-less Worker.handle_error 500 case,
since that was broken in 79011d0 (Include request URL in error
message, 2015-07-08, #1071) but not restored in 1ccebab (prevent
crash when reporting an error, 2016-03-22, #1231).

[1]: https://docs.python.org/2/library/logging.html#logging.Logger.debug

wking added a commit to wking/gunicorn that referenced this pull request Nov 3, 2017

gunicorn: Use exc_info liberally
The argument is documented in [1], and we've been using it in some
cases since 410bcfa (Fix statsd logging to work on Python 3,
2015-04-20, #1010).  This commit goes through all of our log calls and
makes sure we're using it consistently.

For more examples of using exc_info instead of direct traceback calls,
see 0acfb55 (Let logging module handle traceback printing,
2016-02-05, #1201).  The traceback call I'm removing snuck in later
with f4842a5 (Log exception occurring during worker exit, 2016-05-04,
#1254).

I'm removing the "Error processing SSL request" debug messages,
because those will be handled by the subsequent handle_error call.
We've had them, for reasons that I'm not clear on, since 1198cc2
(handle ssl connections, 2012-12-14).

I've restored logging in the URI-less Worker.handle_error 500 case,
since that was broken in 79011d0 (Include request URL in error
message, 2015-07-08, #1071) but not restored in 1ccebab (prevent
crash when reporting an error, 2016-03-22, #1231).

Tests for the lines I've touched may be more trouble than they're
worth.  I've worked up one for a broken worker_exit hook to show what
they look like, but left the others untested for now.

[1]: https://docs.python.org/2/library/logging.html#logging.Logger.debug

wking added a commit to wking/gunicorn that referenced this pull request Nov 3, 2017

gunicorn: Use exc_info liberally
The argument is documented in [1], and we've been using it in some
cases since 410bcfa (Fix statsd logging to work on Python 3,
2015-04-20, #1010).  This commit goes through all of our log calls and
makes sure we're using it consistently.

For more examples of using exc_info instead of direct traceback calls,
see 0acfb55 (Let logging module handle traceback printing,
2016-02-05, #1201).  The traceback call I'm removing snuck in later
with f4842a5 (Log exception occurring during worker exit, 2016-05-04,
#1254).

I'm removing the "Error processing SSL request" debug messages,
because those will be handled by the subsequent handle_error call.
We've had them, for reasons that I'm not clear on, since 1198cc2
(handle ssl connections, 2012-12-14).

I've restored logging in the URI-less Worker.handle_error 500 case,
since that was broken in 79011d0 (Include request URL in error
message, 2015-07-08, #1071) but not restored in 1ccebab (prevent
crash when reporting an error, 2016-03-22, #1231).

Tests for the lines I've touched may be more trouble than they're
worth.  I've worked up one for a broken worker_exit hook to show what
they look like, but left the others untested for now.

[1]: https://docs.python.org/2/library/logging.html#logging.Logger.debug

fofanov pushed a commit to fofanov/gunicorn that referenced this pull request Mar 16, 2018

Merge pull request #1201 from bloodearnest/double_exc
Clean up traceback printing in arbitar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment