Make empty environment variable TRYTOND_LOGGING_LEVEL be treated as unset

This commit is contained in:
Hartmut Goebel
2025-02-08 14:40:10 +01:00
parent 76e335d894
commit d009490e4e
2 changed files with 6 additions and 6 deletions
+3 -4
View File
@@ -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)
+3 -2
View File
@@ -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)