Remove some error logs for canceled requests (as the map page tends to do that quite a lot)

This commit is contained in:
Paul Bienkowski 2022-06-26 13:38:54 +02:00
parent 0cbf03cd56
commit e266a4f40a

View file

@ -39,9 +39,26 @@ c = app.config
api = Blueprint("api", url_prefix="/api") api = Blueprint("api", url_prefix="/api")
auth = Blueprint("auth", url_prefix="") auth = Blueprint("auth", url_prefix="")
import re
TILE_REQUEST_CANCELLED = re.compile(
r"Connection lost before response written.*GET /tiles"
)
class NoConnectionLostFilter(logging.Filter):
def filter(record):
return not TILE_REQUEST_CANCELLED.match(record.getMessage())
logging.getLogger("sanic.error").addFilter(NoConnectionLostFilter)
@app.exception(SanicException, BaseException) @app.exception(SanicException, BaseException)
async def _handle_sanic_errors(_request, exception): async def _handle_sanic_errors(_request, exception):
if exception is asyncio.CancelledError:
return None
log.error("Exception in handler: %s", exception, exc_info=True) log.error("Exception in handler: %s", exception, exc_info=True)
return json_response( return json_response(
{ {