Use valid eventlet logger method
eventlet<=0.17.4 LoggerFileWrapper does not have an error() method so don't try to call it. Instead, use info() which even in newer eventlet versions does exactly the same as error(). This bug only manifests in unit tests once the Related-Bug has been fixed (see Related-Change). Closes-Bug: #1777836 Related-Bug: #1777701 Related-Change: I68fd9d0263a6720aaf0d90b8ea6da1158105ac01 Change-Id: I46190567549826c811ffa51e9a71a38a20d9ce97
This commit is contained in:
parent
642d8748c0
commit
a1cb919930
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user