diff --git a/qsa-api/qsa_api/api/projects.py b/qsa-api/qsa_api/api/projects.py index d0f456e2..add94644 100644 --- a/qsa-api/qsa_api/api/projects.py +++ b/qsa-api/qsa_api/api/projects.py @@ -362,6 +362,7 @@ def project_add_layer(name): try: validate(data, schema) except ValidationError as e: + logger().exception(str(e.message)) return {"error": e.message}, 415 crs = -1 @@ -379,6 +380,7 @@ def project_add_layer(name): data["datetime"], "yyyy-MM-dd HH:mm:ss" ) if not datetime.isValid(): + logger().exception("error Invalid datetime") return {"error": "Invalid datetime"}, 415 rc, err = project.add_layer( @@ -392,6 +394,7 @@ def project_add_layer(name): if rc: return jsonify(rc), 201 else: + logger().exception(str(err)) return {"error": err}, 415 else: return {"error": "Project does not exist"}, 415 diff --git a/qsa-api/qsa_api/api/utils.py b/qsa-api/qsa_api/api/utils.py index ccaf6477..d0b99be8 100644 --- a/qsa-api/qsa_api/api/utils.py +++ b/qsa-api/qsa_api/api/utils.py @@ -2,12 +2,11 @@ import sys import inspect - +from flask import request # Importer request pour récupérer le payload from ..utils import logger def log_request(): - caller_stack = inspect.stack()[1] caller_fct = caller_stack.function @@ -20,4 +19,17 @@ def log_request(): source = inspect.getsource(caller_fn) req_type = source.splitlines()[0].split(".")[1].split("(")[0].upper() - logger().debug(f"[{req_type}] {caller_mod.__name__}.{caller_fct}") + # Récupérer le payload de la requête + payload = None + try: + if request.is_json: + payload = request.get_json() # JSON request body + elif request.form: + payload = request.form.to_dict() # Form data + elif request.data: + payload = request.data.decode("utf-8") # Raw data + except Exception as e: + logger().error(f"Failed to extract payload: {e}") + payload = "Unable to parse payload" + + logger().debug(f"[{req_type}] {caller_mod.__name__}.{caller_fct} - Payload: {payload}") \ No newline at end of file diff --git a/qsa-api/qsa_api/project.py b/qsa-api/qsa_api/project.py index 6e36c30f..92a06809 100644 --- a/qsa-api/qsa_api/project.py +++ b/qsa-api/qsa_api/project.py @@ -403,8 +403,8 @@ def add_layer( lyr = None if t == Qgis.LayerType.Vector: - self.debug("Init vector layer") - lyr = QgsVectorLayer(datasource, name, provider) + self.debug(f"Init vector layer :{datasource} ") + lyr = QgsVectorLayer(datasource, name, "postgres") elif t == Qgis.LayerType.Raster: self.debug("Init raster layer") lyr = QgsRasterLayer(datasource, name, provider) diff --git a/qsa-api/qsa_api/raster/empty.tif b/qsa-api/qsa_api/raster/empty.tif index c98cb6f7..c6bb779d 100644 Binary files a/qsa-api/qsa_api/raster/empty.tif and b/qsa-api/qsa_api/raster/empty.tif differ