diff --git a/swh/web/api/apiresponse.py b/swh/web/api/apiresponse.py --- a/swh/web/api/apiresponse.py +++ b/swh/web/api/apiresponse.py @@ -4,6 +4,7 @@ # See top-level LICENSE file for more information import json +import logging import traceback from typing import Any, Dict, Optional @@ -23,6 +24,8 @@ from swh.web.common.utils import gen_path_info, shorten_path from swh.web.config import get_config +logger = logging.Logger(__name__) + def compute_link_header(rv: Dict[str, Any], options: Dict[str, Any]) -> Dict[str, Any]: """Add Link header in returned value results. @@ -201,6 +204,7 @@ if get_config()["debug"]: error_data["traceback"] = traceback.format_exc() + logger.error(error_data["traceback"]) return make_api_response(request, error_data, doc_data, options=error_opts) diff --git a/swh/web/common/exc.py b/swh/web/common/exc.py --- a/swh/web/common/exc.py +++ b/swh/web/common/exc.py @@ -3,6 +3,7 @@ # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information +import logging import traceback import sentry_sdk @@ -13,6 +14,8 @@ from swh.web.config import get_config +logger = logging.Logger(__name__) + class BadInputExc(ValueError): """Wrong request to the api. @@ -135,6 +138,7 @@ error_description = "%s: %s" % (type(exc).__name__, str(exc)) if get_config()["debug"]: error_description = traceback.format_exc() + logger.error(error_description) if isinstance(exc, BadInputExc): error_code = 400 if isinstance(exc, ForbiddenExc):