Sending OAuth Server errors to the log instead of printing to stdout

This commit is contained in:
Michael Lazar
2018-03-20 14:04:03 -04:00
parent f4cdebfa98
commit be4c9c125f
3 changed files with 16 additions and 5 deletions

View File

@@ -24,6 +24,18 @@ _logger = logging.getLogger(__name__)
INDEX = os.path.join(TEMPLATES, 'index.html')
class OAuthHTTPServer(HTTPServer):
def handle_error(self, request, client_address):
"""
The default HTTPServer's error handler prints the request traceback
to stdout, which breaks the curses display.
Override it to log to a file instead.
"""
_logger.exception('Error processing request in OAuth HTTP Server')
class OAuthHandler(BaseHTTPRequestHandler):
# params are stored as a global because we don't have control over what
@@ -160,7 +172,7 @@ class OAuthHelper(object):
if self.server is None:
address = ('', self.config['oauth_redirect_port'])
self.server = HTTPServer(address, OAuthHandler)
self.server = OAuthHTTPServer(address, OAuthHandler)
if self.term.display:
# Open a background browser (e.g. firefox) which is non-blocking.