Fix startup logic
This commit is contained in:
parent
3ef5e81b48
commit
6eb572cb75
@ -77,9 +77,18 @@ def create_app(test_config=None, instance_path=None):
|
||||
if app.config.get("LOG_TO_STDERR"):
|
||||
log_kwargs["stream"] = sys.stderr
|
||||
else:
|
||||
log_kwargs["filename"] = app.config.get("LOG_FILE", "brecaltest.log")
|
||||
log_file = app.config.get("LOG_FILE", "brecaltest.log")
|
||||
if not os.path.isabs(log_file):
|
||||
log_file = os.path.join(app.instance_path, log_file)
|
||||
log_dir = os.path.dirname(log_file)
|
||||
if log_dir and not os.path.exists(log_dir):
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
log_kwargs["filename"] = log_file
|
||||
# Force handler setup so WSGI doesn't keep the default stderr handler.
|
||||
try:
|
||||
logging.basicConfig(level=log_level, force=True, **log_kwargs)
|
||||
except Exception:
|
||||
logging.basicConfig(level=log_level, force=True, stream=sys.stderr, **{"format": log_kwargs["format"]})
|
||||
|
||||
if app.config.get("SECRET_KEY"):
|
||||
os.environ["SECRET_KEY"] = app.config["SECRET_KEY"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user