diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 5bbe604b5c..fe250d5354 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -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): diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 6c9d485942..5c6b91c0cb 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -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):