-
Notifications
You must be signed in to change notification settings - Fork 792
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
Gevent ssl traceback #1298
Gevent ssl traceback #1298
Conversation
Provides WSGIServer with a logger for INFO log messages and ERROR log messages. https://www.gevent.org/api/gevent.pywsgi.html#gevent.pywsgi.WSGIServer
7684120
to
16de12b
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1298 +/- ##
===========================================
- Coverage 30.68% 30.63% -0.05%
===========================================
Files 449 450 +1
Lines 13467 13489 +22
===========================================
+ Hits 4132 4133 +1
- Misses 9335 9356 +21
Continue to review full report at Codecov.
|
@@ -54,6 +58,7 @@ def run_monkey_island(): | |||
|
|||
connect_to_mongodb() | |||
|
|||
_configure_gevent_exception_handling(logger, Path(config_options.data_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass logger
as an argument here? Won't it just be able to use logger
because of logger = logging.getLogger(__name__)
above?
# Send gevent's exception output to a log file. | ||
# https://www.gevent.org/api/gevent.hub.html#gevent.hub.Hub.exception_stream | ||
hub.exception_stream = gevent_exception_log | ||
hub.handle_error = GeventHubErrorHandler(hub, logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass logger
as an argument here? Why not have logger = logging.getLogger(__name__)
in monkey_island/cc/setup/gevent_hub_error_handler.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that all of the gevent objects (i.e. Hub and WSGIServer) have the same logger. It also has the added benefit of making the dependencies of GeventHubErrorHandler
explicit. Unlike other classes, this class doesn't use a logger to log information about itself. Rather, it uses a logger object as part of an exception handling routine on behalf of another component. In other words, logging is part of this component's primary function, so it should be explicit in its interface/dependencies.
By default, gevent prints exceptions and tracebacks to stderr. This is obnoxious as it results in large tracebacks intermixed with the output that the logger prints to the console. This commit redirects this data to {DATA_DIR}/gevent_exceptions.log. Unfortunately, this would mean that the user might be left without any indication these exceptions had occurred, unless they take the time to inspect the gevent_exceptions.log. Therefore, when an excepion occurs, a message with just the exception (not the traceback) is logged to WARNING. Fixes #859
16de12b
to
96fc330
Compare
What does this PR do?
Fixes #859
The gevent hub has 2 mechanisms for controlling how errors (tracebacks) are handled.
exception_stream
controls where tracebacks are written (default=stderr): https://www.gevent.org/api/gevent.hub.html#gevent.hub.Hub.exception_streamhandle_error()
method controls what happens when an error is encountered: https://www.gevent.org/api/gevent.hub.html#gevent.hub.Hub.handle_errorIf
exception_stream
is set, the user may not get any indication that a gevent error occurred. To solve this, thehandle_error()
functionality is wrapped and the exception (not traceback) is logged to WARNING.PR Checklist
Was the documentation framework updated to reflect the changes?Testing Checklist
Added relevant unit tests?Screenshots