Consistent use of error loggers (#2109)
* Consistent use of error loggers * Fix tests
This commit is contained in:
@@ -276,7 +276,7 @@ def test_handle_request_with_nested_sanic_exception(app, monkeypatch, caplog):
|
||||
assert response.status == 500
|
||||
assert "Mock SanicException" in response.text
|
||||
assert (
|
||||
"sanic.root",
|
||||
"sanic.error",
|
||||
logging.ERROR,
|
||||
f"Exception occurred while handling uri: 'http://127.0.0.1:{port}/'",
|
||||
) in caplog.record_tuples
|
||||
|
||||
@@ -113,9 +113,9 @@ def test_logging_pass_customer_logconfig():
|
||||
def test_log_connection_lost(app, debug, monkeypatch):
|
||||
""" Should not log Connection lost exception on non debug """
|
||||
stream = StringIO()
|
||||
root = logging.getLogger("sanic.root")
|
||||
root.addHandler(logging.StreamHandler(stream))
|
||||
monkeypatch.setattr(sanic.server, "logger", root)
|
||||
error = logging.getLogger("sanic.error")
|
||||
error.addHandler(logging.StreamHandler(stream))
|
||||
monkeypatch.setattr(sanic.server, "error_logger", error)
|
||||
|
||||
@app.route("/conn_lost")
|
||||
async def conn_lost(request):
|
||||
|
||||
@@ -156,7 +156,7 @@ def test_middleware_response_raise_cancelled_error(app, caplog):
|
||||
|
||||
assert response.status == 503
|
||||
assert (
|
||||
"sanic.root",
|
||||
"sanic.error",
|
||||
logging.ERROR,
|
||||
"Exception occurred while handling uri: 'http://127.0.0.1:42101/'",
|
||||
) not in caplog.record_tuples
|
||||
@@ -174,7 +174,7 @@ def test_middleware_response_raise_exception(app, caplog):
|
||||
assert response.status == 404
|
||||
# 404 errors are not logged
|
||||
assert (
|
||||
"sanic.root",
|
||||
"sanic.error",
|
||||
logging.ERROR,
|
||||
"Exception occurred while handling uri: 'http://127.0.0.1:42101/'",
|
||||
) not in caplog.record_tuples
|
||||
|
||||
Reference in New Issue
Block a user