Merge "Use valid eventlet logger method"
This commit is contained in:
commit
c3ea2f0909
@ -432,8 +432,13 @@ class SwiftHttpProtocol(wsgi.HttpProtocol):
|
|||||||
"""
|
"""
|
||||||
Redirect logging other messages by the underlying WSGI software.
|
Redirect logging other messages by the underlying WSGI software.
|
||||||
"""
|
"""
|
||||||
logger = getattr(self.server.app, 'logger', None) or self.server.log
|
logger = getattr(self.server.app, 'logger', None)
|
||||||
logger.error('ERROR WSGI: ' + f, *a)
|
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):
|
class SwiftHttpProxiedProtocol(SwiftHttpProtocol):
|
||||||
|
@ -1043,14 +1043,14 @@ class TestSwiftHttpProtocol(unittest.TestCase):
|
|||||||
delattr(proto_obj.server.app, 'logger')
|
delattr(proto_obj.server.app, 'logger')
|
||||||
|
|
||||||
proto_obj.log_message('a%sc', 'b')
|
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.mock_calls)
|
||||||
|
|
||||||
proto_obj.server.log.reset_mock()
|
proto_obj.server.log.reset_mock()
|
||||||
proto_obj.server.app.logger = None
|
proto_obj.server.app.logger = None
|
||||||
|
|
||||||
proto_obj.log_message('a%sc', 'b')
|
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.mock_calls)
|
||||||
|
|
||||||
def test_swift_http_protocol_parse_request_no_proxy(self):
|
def test_swift_http_protocol_parse_request_no_proxy(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user