CHG Log instead of print the error in healthcheck
+import traceback
from flask import Flask
@@ -5,6 +6,7 @@ def add_healthcheck(app: Flask):
from anubis.utils.http.decorators import json_response
from anubis.models import Config
from anubis.utils.cache import cache_health
+ from anubis.utils.logging import logger
from anubis.env import env
@app.route("/")
@@ -41,22 +43,22 @@ def add_healthcheck(app: Flask):
Config.query.all()
# If there is any issue, mark the db
- # connection as Unhealthy
+ # connection as Unhealthy and log the error
except Exception as e:
status["db"] = "Unhealthy"
status_code = 500
- print(e)
+ logger.error(traceback.format_exc())
# Attempt to connect to cache
try:
cache_health()
# If there is any issue, mark the cache
- # connection as Unhealthy
+ # connection as Unhealthy and log the error
except Exception as e:
status["cache"] = "Unhealthy"
status_code = 500
- print(e)
+ logger.error(traceback.format_exc())
# Pass back status and status_code
return status, status_code
