Removed match for python < 3.10

This commit is contained in:
jeancf 2022-12-21 09:41:59 +01:00
parent 333470e623
commit ed3e0b1fd6

View File

@ -634,24 +634,29 @@ def main(argv):
datefmt='%Y-%m-%d %H:%M:%S', datefmt='%Y-%m-%d %H:%M:%S',
) )
# Set level of logging # Set default level of logging
log_level = logging.WARNING log_level = logging.WARNING
match TOML['options']['log_level'].upper():
case 'DEBUG': # log level as an uppercase string from config
log_level = logging.DEBUG ll_str = TOML['options']['log_level'].upper()
case 'INFO':
log_level = logging.INFO if ll_str == "DEBUG":
case 'WARNING': log_level = logging.DEBUG
log_level = logging.WARNING elif ll_str == "INFO":
case 'ERROR': log_level = logging.INFO
log_level = logging.ERROR elif ll_str == "WARNING":
case 'CRITICAL': log_level = logging.WARNING
log_level = logging.CRITICAL elif ll_str == "ERROR":
case 'OFF': log_level = logging.ERROR
# Disable all logging elif ll_str == "CRITICAL":
logging.disable(logging.CRITICAL) log_level == logging.CRITICAL
case _: elif ll_str == "OFF":
logging.error('Invalid log_level %s in config file. Using WARNING.', str(TOML['options']['log_level'])) # Disable all logging
logging.disable(logging.CRITICAL)
else:
logging.error('Invalid log_level %s in config file. Using WARNING.', str(TOML['options']['log_level']))
# Set desired level of logging
logger = logging.getLogger() logger = logging.getLogger()
logger.setLevel(log_level) logger.setLevel(log_level)