Skip to content

Commit

Permalink
adjust logger
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc committed Oct 30, 2023
1 parent 125ebc0 commit 999795f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 9 additions & 7 deletions src/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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

# ----------------------------------------------------------------------------
Expand Down

0 comments on commit 999795f

Please sign in to comment.