diff --git a/.secrets.baseline b/.secrets.baseline index 5901ed1..c96422d 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -169,7 +169,7 @@ "filename": "gen3workflow/config-default.yaml", "hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3", "is_verified": false, - "line_number": 37 + "line_number": 39 } ], "migrations/versions/e1886270d9d2_create_system_key_table.py": [ @@ -209,5 +209,5 @@ } ] }, - "generated_at": "2025-01-09T21:36:04Z" + "generated_at": "2025-01-24T23:29:16Z" } diff --git a/gen3workflow/app.py b/gen3workflow/app.py index 13b0a77..f62255b 100644 --- a/gen3workflow/app.py +++ b/gen3workflow/app.py @@ -1,6 +1,7 @@ from fastapi import FastAPI import httpx from importlib.metadata import version +import logging import os from cdislogging import get_logger @@ -18,13 +19,13 @@ def get_app(httpx_client=None) -> FastAPI: logger.info("Initializing app") config.validate() - debug = config["DEBUG"] + debug = config["APP_DEBUG"] log_level = "debug" if debug else "info" app = FastAPI( title="Gen3Workflow", version=version("gen3workflow"), - debug=debug, + debug=config["APP_DEBUG"], root_path=config["DOCS_URL_PREFIX"], ) app.async_client = httpx_client or httpx.AsyncClient() diff --git a/gen3workflow/config-default.yaml b/gen3workflow/config-default.yaml index 5d79e16..f19ce85 100644 --- a/gen3workflow/config-default.yaml +++ b/gen3workflow/config-default.yaml @@ -3,7 +3,9 @@ ########## HOSTNAME: localhost -DEBUG: false +APP_DEBUG: false +# httpx debug mode is very verbose, so the setting is separate from the main app debug mode +HTTPX_DEBUG: false DOCS_URL_PREFIX: /gen3workflow # override the default Arborist URL; ignored if already set as an environment variable diff --git a/gen3workflow/config.py b/gen3workflow/config.py index 77ec3a6..99b63be 100644 --- a/gen3workflow/config.py +++ b/gen3workflow/config.py @@ -42,7 +42,8 @@ def validate_top_level_configs(self) -> None: "additionalProperties": False, "properties": { "HOSTNAME": {"type": "string"}, - "DEBUG": {"type": "boolean"}, + "APP_DEBUG": {"type": "boolean"}, + "HTTPX_DEBUG": {"type": "boolean"}, "DOCS_URL_PREFIX": {"type": "string"}, "ARBORIST_URL": {"type": ["string", "null"]}, "MOCK_AUTH": {"type": "boolean"}, diff --git a/gunicorn.conf.py b/gunicorn.conf.py index 3138302..ab166a0 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -28,14 +28,17 @@ def __init__(self, cfg): super().__init__(cfg) self._remove_handlers(logging.getLogger()) + + # httpx uses the log level it sees first when the client is initialized, which is this one cdislogging.get_logger( - None, log_level="debug" if app_config["DEBUG"] else "warn" + None, log_level="debug" if app_config["HTTPX_DEBUG"] else "warn" ) + for logger_name in ["gunicorn", "gunicorn.error", "gunicorn.access"]: self._remove_handlers(logging.getLogger(logger_name)) cdislogging.get_logger( logger_name, - log_level="debug" if app_config["DEBUG"] else "info", + log_level="debug" if app_config["APP_DEBUG"] else "info", ) diff --git a/tests/test-gen3workflow-config.yaml b/tests/test-gen3workflow-config.yaml index b3aff15..f67d2b8 100644 --- a/tests/test-gen3workflow-config.yaml +++ b/tests/test-gen3workflow-config.yaml @@ -1,4 +1,4 @@ -DEBUG: true +APP_DEBUG: true ARBORIST_URL: http://test-arborist-server S3_ENDPOINTS_AWS_ACCESS_KEY_ID: test-aws-key-id