diff options
author | Frederick Muriuki Muriithi | 2024-04-10 10:55:51 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-04-10 10:55:51 +0300 |
commit | acdbc30fd8d12d25f48a2ea839a6c2eb91527b95 (patch) | |
tree | ee3bad7b202b76bc162403c220d054779151788b /qc_app | |
parent | 061a40c14f3adf39c794aa0ddace4835f9282e9b (diff) | |
download | gn-uploader-acdbc30fd8d12d25f48a2ea839a6c2eb91527b95.tar.gz |
logging: Set up logging in wsgi.py
Make flask use the gunicorn loggers when run under gunicorn,
otherwise, use our custom logging.
Putting the logging setup inside `create_app(…)` would cause each
worker to override the gunicorn loggers, meaning we were not receiving
the logs, especially for `debug(…)` calls.
Diffstat (limited to 'qc_app')
-rw-r--r-- | qc_app/__init__.py | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/qc_app/__init__.py b/qc_app/__init__.py index c9756a1..88e65be 100644 --- a/qc_app/__init__.py +++ b/qc_app/__init__.py @@ -1,9 +1,7 @@ """The Quality-Control Web Application entry point""" import os -import sys import logging from pathlib import Path -from logging import StreamHandler from flask import Flask @@ -20,15 +18,6 @@ def override_settings_with_envvars( for setting in (key for key in app.config if key not in ignore): app.config[setting] = os.environ.get(setting) or app.config[setting] -def setup_logging(app: Flask): - """Setup application logging""" - handler_stderr = StreamHandler(stream=sys.stderr) - app.logger.addHandler(handler_stderr) - - rootlogger = logging.getLogger() - rootlogger.addHandler(handler_stderr) - rootlogger.setLevel(app.config["LOG_LEVEL"]) - def create_app(): """The application factory""" app = Flask(__name__) @@ -38,7 +27,6 @@ def create_app(): app.config.from_envvar("QCAPP_CONF") # Override defaults with instance path override_settings_with_envvars(app, ignore=tuple()) - setup_logging(app) if "QCAPP_SECRETS" in os.environ: app.config.from_envvar("QCAPP_SECRETS") |