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

View file

@ -9,9 +9,13 @@ from platypush.backend.http.app.utils import get_routes
def initialize_logger(): def initialize_logger():
logger = logging.getLogger('werkzeug') logger = logging.getLogger('werkzeug')
log_conf = Config.get('logging') try:
if 'level' in log_conf: log_conf = Config.get('logging')
logger.setLevel(log_conf['level']) 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 ## Webapp initialization