Don't fail hard if the web app is initialized without access to a configuration file (e.g. from a ReadTheDocs build environment)

This commit is contained in:
Fabio Manganiello 2021-02-21 23:30:05 +01:00
parent aa5cbbce28
commit 10eb0c12aa
1 changed files with 7 additions and 3 deletions

View File

@ -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