aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-07-17 11:43:50 -0500
committerFrederick Muriuki Muriithi2024-07-17 11:45:19 -0500
commitd601e85f9e423d0e5cd489dfb26412981ddcd50d (patch)
tree061facc18eca0c4be6e4471c03906951059f14a9 /gn2/wqflask
parentcef21502dd5f60bfa9c47d1e32539da41a13fba2 (diff)
downloadgenenetwork2-d601e85f9e423d0e5cd489dfb26412981ddcd50d.tar.gz
Reorganise code to do ALL configs at the top and then logging
In order to ensure that logging works as expected, make sure it is set up after all settings are in place.
Diffstat (limited to 'gn2/wqflask')
-rw-r--r--gn2/wqflask/__init__.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/gn2/wqflask/__init__.py b/gn2/wqflask/__init__.py
index d651005a..ce42ce4e 100644
--- a/gn2/wqflask/__init__.py
+++ b/gn2/wqflask/__init__.py
@@ -77,7 +77,7 @@ def dev_loggers(appl: Flask) -> None:
root_logger = logging.getLogger()
root_logger.addHandler(stderr_handler)
- root_logger.setLevel(appl.config.get("LOGLEVEL", "WARNING"))
+ root_logger.setLevel(appl.config.get("LOG_LEVEL", "WARNING"))
def gunicorn_loggers(appl: Flask) -> None:
@@ -94,12 +94,20 @@ def setup_logging(appl: Flask) -> None:
app = Flask(__name__)
-setup_logging(app)
-
+## BEGIN: Setup configurations ##
# See http://flask.pocoo.org/docs/config/#configuring-from-files
# Note no longer use the badly named WQFLASK_OVERRIDES (nyi)
app.config.from_object('gn2.default_settings')
app.config.from_envvar('GN2_SETTINGS')
+app.config["SESSION_REDIS"] = redis.from_url(app.config["REDIS_URL"])
+# BEGIN: SECRETS -- Should be the last of the settings to load
+secrets_file = Path(app.config.get("GN2_SECRETS", "")).absolute()
+if secrets_file.exists() and secrets_file.is_file():
+ app.config.from_pyfile(str(secrets_file))
+# END: SECRETS
+## END: Setup configurations ##
+setup_logging(app)
+### DO NOT USE logging BEFORE THIS POINT!!!! ###
app.jinja_env.globals.update(
undefined=jinja2.StrictUndefined,
@@ -110,14 +118,6 @@ app.jinja_env.globals.update(
num_collections=numcoll,
datetime=datetime)
-app.config["SESSION_REDIS"] = redis.from_url(app.config["REDIS_URL"])
-
-## BEGIN: SECRETS -- Should be the last of the settings to load
-secrets_file = Path(app.config.get("GN2_SECRETS", "")).absolute()
-if secrets_file.exists() and secrets_file.is_file():
- app.config.from_pyfile(str(secrets_file))
-## END: SECRETS
-
# Registering blueprints
app.register_blueprint(glossary_blueprint, url_prefix="/glossary")