diff --git a/trytond/trytond/application.py b/trytond/trytond/application.py index f30bb7296e..bc10f0ebaa 100644 --- a/trytond/trytond/application.py +++ b/trytond/trytond/application.py @@ -9,12 +9,11 @@ from io import StringIO __all__ = ['app'] # Logging must be set before importing -logging_config = os.environ.get('TRYTOND_LOGGING_CONFIG') -logging_level = int(os.environ.get( - 'TRYTOND_LOGGING_LEVEL', default=logging.ERROR)) -if logging_config: +if logging_config := os.environ.get('TRYTOND_LOGGING_CONFIG'): logging.config.fileConfig(logging_config) else: + logging_level = int( + os.environ.get('TRYTOND_LOGGING_LEVEL') or logging.ERROR) logformat = ('%(process)s %(thread)s [%(asctime)s] ' '%(levelname)s %(name)s %(message)s') level = max(logging_level, logging.NOTSET) diff --git a/trytond/trytond/commandline.py b/trytond/trytond/commandline.py index 99b4d556a5..a7b0de783b 100644 --- a/trytond/trytond/commandline.py +++ b/trytond/trytond/commandline.py @@ -188,8 +188,9 @@ def config_log(options): else: logformat = ('%(process)s %(thread)s [%(asctime)s] ' '%(levelname)s %(name)s %(message)s') - if not options.verbose and 'TRYTOND_LOGGING_LEVEL' in os.environ: - logging_level = int(os.environ['TRYTOND_LOGGING_LEVEL']) + if not options.verbose: + logging_level = int( + os.environ.get('TRYTOND_LOGGING_LEVEL') or logging.ERROR) level = max(logging_level, logging.NOTSET) else: level = max(logging.ERROR - options.verbose * 10, logging.NOTSET)