From a720b52c56ea0ac707ac9e3ea0eda34134e5f6dd Mon Sep 17 00:00:00 2001 From: David Date: Wed, 11 Oct 2023 14:57:49 +0200 Subject: [PATCH] fix logging yaml being in a different place for pyinstaller package --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index c816dad..9d898a7 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import os import yaml import uvicorn import multiprocessing @@ -9,9 +10,10 @@ from router import router -with open('logging.yaml') as f: - config = yaml.load(f, Loader=yaml.FullLoader) - logging.config.dictConfig(config) +if os.path.exists("logging.yaml"): + with open('logging.yaml') as f: + config = yaml.load(f, Loader=yaml.FullLoader) + logging.config.dictConfig(config) app = FastAPI()