From 0dbc9076392c34eca638cfb2c7d99bfea4f90419 Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Mon, 13 May 2024 10:58:10 +0100 Subject: [PATCH] using default logger file if no env variable set --- coordinator/ProcessorUtils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/coordinator/ProcessorUtils.py b/coordinator/ProcessorUtils.py index fee2ea7..da7e13a 100644 --- a/coordinator/ProcessorUtils.py +++ b/coordinator/ProcessorUtils.py @@ -502,9 +502,6 @@ def setup_logging(job_file_path: str, is_live: bool, log_level: str): :return: """ - assert 'LOGGING_CONFIG' in os.environ - logging_config_env = os.environ['LOGGING_CONFIG'] - assert os.path.exists(logging_config_env) # get the email credentials file path from the environment variables assert 'EMAIL_CRED' in os.environ @@ -522,7 +519,16 @@ def setup_logging(job_file_path: str, is_live: bool, log_level: str): arg_string = ' '.join(sys.argv) # load logging json config file - json_file_path = logging_config_env + + # if there is no value set for the LOGGING_CONFIG file, set a default path. + if not 'LOGGING_CONFIG' in os.environ: + log_config_path_project = os.path.join(os.path.dirname(__file__), "../configs", "logger", "template_log_config.json") + print(f"ENVIRONMENT VARIABLE 'LOGGING_CONFIG' IS NOT SET, UISING DEFAULT FILE - {log_config_path_project}") + else: + log_config_path_project = os.environ['LOGGING_CONFIG'] + + assert os.path.exists(log_config_path_project) + json_file_path = log_config_path_project with open(json_file_path, 'r') as f: log_config_dict = json.load(f) -- GitLab