From be3fe5472b8edafd83801ae2e2214a4c6fe2a21d Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Mon, 24 Oct 2022 15:47:17 -0600 Subject: [PATCH] Update logging configuration --- docker-entrypoint.sh | 3 +++ geomagio/api/app.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7c05ad6e..0f95ec97 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -9,10 +9,13 @@ if [ "${WEBSERVICE}" = "false" ]; then # run arguments as command, or bash prompt if no arguments exec "${@:-/bin/bash}" else + export LOG_BASIC_CONFIG="${LOG_BASIC_CONFIG:-true}" + export LOG_LEVEL="${LOG_LEVEL:-INFO}" # run gunicorn server for web service exec gunicorn \ --access-logfile - \ --bind 0.0.0.0:8000 \ + --log-level "${LOG_LEVEL}" \ --threads 2 \ --workers 2 \ --worker-class uvicorn.workers.UvicornWorker \ diff --git a/geomagio/api/app.py b/geomagio/api/app.py index 47fb64a4..618fe8ed 100644 --- a/geomagio/api/app.py +++ b/geomagio/api/app.py @@ -15,10 +15,10 @@ from starlette.responses import RedirectResponse from . import secure, ws from .db import database -# configure logging -DEBUG = os.getenv('DEBUG', 'false') -LOG_LEVEL = logging.DEBUG if DEBUG == "true" else logging.INFO -logging.basicConfig(level=LOG_LEVEL) +LOG_BASIC_CONFIG = os.getenv("LOG_BASIC_CONFIG", "false") +LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") +if LOG_BASIC_CONFIG == "true": + logging.basicConfig(level=LOG_LEVEL) app = FastAPI() app.mount("/ws/secure", secure.app) -- GitLab