aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-07-17 11:43:50 -0500
committerAlexander_Kabui2024-08-28 15:02:46 +0300
commit97d2f89ac7b992f752d7d782e631edbc8408a120 (patch)
treec3a6ba1b823d4d65f9c24334147df1b57f5291e1 /gn2/wqflask
parentd055d932ce6763df041da45d9d1856f7b72bb378 (diff)
downloadgenenetwork2-97d2f89ac7b992f752d7d782e631edbc8408a120.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")