From 40e91a7d2bbdd8a1836731c5a04f9255aae4c36f Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Mon, 10 Aug 2026 16:56:58 +0200 Subject: [PATCH] better erro logging --- cloud/app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cloud/app.py b/cloud/app.py index e8f14aa..e5a99e8 100644 --- a/cloud/app.py +++ b/cloud/app.py @@ -5,7 +5,7 @@ import uuid import datetime import sys import json -from flask import Flask, request, jsonify +from flask import Flask, request, jsonify, current_app from pymongo import MongoClient from APIs import generate, EdamamAPI from APIs.mqtt import send_command @@ -79,7 +79,7 @@ async def cooking_params(): f.write(base64.b64decode(camera_image_b64)) data["camera_image"] = filepath except Exception as e: - print(f"[Error] Failed to save camera image: {str(e)}") + current_app.logger.exception("Failed to save camera image") return jsonify({"error": f"Failed to save camera image: {str(e)}"}), 500 # 2. Run Vision Safety Check & Cook Planner Concurrently @@ -98,13 +98,13 @@ async def cooking_params(): safety_result, cook_plan = await asyncio.gather(safety_task, planner_task) except Exception as e: - print(f"[Error] Exception during safety check or cook planning: {str(e)}") + current_app.logger.exception("Exception during safety check or cook planning") return jsonify({"error": f"Task execution failed: {str(e)}"}), 500 # 3. Evaluate Safety Result data["safety_check"] = safety_result if not safety_result.get("is_safe", True): - print(f"[Safety Warning] Unsafe dish detected: {safety_result}") + current_app.logger.warning(f"Unsafe dish detected: {safety_result}") return jsonify({ "error": "Safety hazard detected in microwave area", "is_safe": False, @@ -123,7 +123,7 @@ async def cooking_params(): return jsonify(cook_plan), 201 except Exception as e: - print(f"[Error] Exception in /cooking-params: {str(e)}") + current_app.logger.exception("Exception in /cooking-params") @app.route("/telemetry", methods=["POST"]) def telemetry():