From 32f94ccfa047fd758b1f0aa0b26ebc4cdd718204 Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Mon, 24 Oct 2022 14:19:06 -0600
Subject: [PATCH] api: logging environment variable for webservice

---
 geomagio/api/app.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/geomagio/api/app.py b/geomagio/api/app.py
index e206d680..47fb64a4 100644
--- a/geomagio/api/app.py
+++ b/geomagio/api/app.py
@@ -6,13 +6,19 @@ and can be run using uvicorn, or any other ASGI server:
     uvicorn geomagio.api:app
 
 """
+import logging
+import os
+
 from fastapi import FastAPI
 from starlette.responses import RedirectResponse
 
+from . import secure, ws
 from .db import database
-from . import secure
-from . import ws
 
+# configure logging
+DEBUG = os.getenv('DEBUG', 'false')
+LOG_LEVEL = logging.DEBUG if DEBUG == "true" else logging.INFO
+logging.basicConfig(level=LOG_LEVEL)
 
 app = FastAPI()
 app.mount("/ws/secure", secure.app)
-- 
GitLab