Merge "Use valid eventlet logger method"

This commit is contained in:
Zuul 2018-06-20 18:48:18 +00:00 committed by Gerrit Code Review
commit c3ea2f0909
2 changed files with 9 additions and 4 deletions

View File

@ -432,8 +432,13 @@ class SwiftHttpProtocol(wsgi.HttpProtocol):
"""
Redirect logging other messages by the underlying WSGI software.
"""
logger = getattr(self.server.app, 'logger', None) or self.server.log
logger.error('ERROR WSGI: ' + f, *a)
logger = getattr(self.server.app, 'logger', None)
if logger:
logger.error('ERROR WSGI: ' + f, *a)
else:
# eventlet<=0.17.4 doesn't have an error method, and in newer
# versions the output from error is same as info anyway
self.server.log.info('ERROR WSGI: ' + f, *a)
class SwiftHttpProxiedProtocol(SwiftHttpProtocol):

View File

@ -1043,14 +1043,14 @@ class TestSwiftHttpProtocol(unittest.TestCase):
delattr(proto_obj.server.app, 'logger')
proto_obj.log_message('a%sc', 'b')
self.assertEqual([mock.call.error('ERROR WSGI: a%sc', 'b')],
self.assertEqual([mock.call.info('ERROR WSGI: a%sc', 'b')],
proto_obj.server.log.mock_calls)
proto_obj.server.log.reset_mock()
proto_obj.server.app.logger = None
proto_obj.log_message('a%sc', 'b')
self.assertEqual([mock.call.error('ERROR WSGI: a%sc', 'b')],
self.assertEqual([mock.call.info('ERROR WSGI: a%sc', 'b')],
proto_obj.server.log.mock_calls)
def test_swift_http_protocol_parse_request_no_proxy(self):