From 999795fabe04922f159bdb740fd7ffe5f192d6e8 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Mon, 30 Oct 2023 14:43:57 -0500 Subject: [PATCH] adjust logger --- src/app.py | 3 ++- src/data_loading.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app.py b/src/app.py index 35714f6..91ff44f 100644 --- a/src/app.py +++ b/src/app.py @@ -122,9 +122,10 @@ app = Flask(__name__) app.debug = True gunicorn_logger = logging.getLogger('gunicorn.error') -app.logger = gunicorn_logger +app.logger = logging.getLogger("datastore_app") app.logger.handlers = gunicorn_logger.handlers app.logger.setLevel(logging.DEBUG) + logger = logging.getLogger('werkzeug') logger.handlers = gunicorn_logger.handlers diff --git a/src/data_loading.py b/src/data_loading.py index f803ead..690a410 100644 --- a/src/data_loading.py +++ b/src/data_loading.py @@ -16,6 +16,8 @@ import logging files_api_root = os.environ.get('FILES_API_ROOT') portal_api_root = os.environ.get('PORTAL_API_ROOT') +logger = logging.getLogger("datastore_app") + # ---------------------------------------------------------------------------- # Updating data checks @@ -238,7 +240,7 @@ def get_api_consort_data(tapis_token, return consort_data_json else: - logging.exception("Unauthorized attempt to access Consort data") + logger.exception("Unauthorized attempt to access Consort data") return None except Exception as e: @@ -283,7 +285,7 @@ def get_api_imaging_data(tapis_token): return imaging_data_json else: - logging.exception("Unauthorized attempt to access Imaging data") + logger.exception("Unauthorized attempt to access Imaging data") return None except Exception as e: @@ -340,7 +342,7 @@ def get_api_blood_data(tapis_token): return blood_data_json, request_status else: - logging.exception("Unauthorized attempt to access Blood data") + logger.exception("Unauthorized attempt to access Blood data") return None except Exception as e: @@ -375,7 +377,7 @@ def get_api_subjects_json(tapis_token): return subjects_json else: - logging.exception("Unauthorized attempt to access Subjects data") + logger.exception("Unauthorized attempt to access Subjects data") return None except Exception as e: @@ -390,16 +392,16 @@ def make_request_with_retry(url, cookies): # Get Tapis token if authorized to access data files def get_tapis_token(api_request): try: - logging.info("Requesting for tapis token") + logger.info("Requesting for tapis token") response = make_request_with_retry(portal_api_root + '/auth/tapis/', api_request.cookies) if response: tapis_token = response.json()['token'] return tapis_token else: - logging.exception("Unauthorized to access tapis token") + logger.exception("Unauthorized to access tapis token") raise Exception except Exception as e: - logging.exception('portal api error: {}'.format(e)) + logger.exception('portal api error: {}'.format(e)) return False # ----------------------------------------------------------------------------