From 10eb0c12aa0b1814c5516c27d4a0f49c62834cd1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 21 Feb 2021 23:30:05 +0100 Subject: [PATCH] Don't fail hard if the web app is initialized without access to a configuration file (e.g. from a ReadTheDocs build environment) --- platypush/backend/http/app/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platypush/backend/http/app/__init__.py b/platypush/backend/http/app/__init__.py index cb7af88a15..e04208df99 100644 --- a/platypush/backend/http/app/__init__.py +++ b/platypush/backend/http/app/__init__.py @@ -9,9 +9,13 @@ from platypush.backend.http.app.utils import get_routes def initialize_logger(): logger = logging.getLogger('werkzeug') - log_conf = Config.get('logging') - if 'level' in log_conf: - logger.setLevel(log_conf['level']) + try: + log_conf = Config.get('logging') + if 'level' in log_conf: + logger.setLevel(log_conf['level']) + except Exception as e: + logger.warning('Could not read logging level') + logger.exception(e) ## Webapp initialization