Commit d0b1391b authored by Trevor Cappallo's avatar Trevor Cappallo
Browse files

do not fail on missing config file

parent af69e2fd
......@@ -212,11 +212,14 @@ def setup(config_file=None, logger_name=None, log_filename=None, log_root_dir=No
}
# If config file provided, replace any None values with loaded value.
if config_file:
with open(config_file, 'r') as f:
loaded_config = json.load(f)
for key, val in loaded_config.items():
if key in config and val is None:
config[key] = val
if not os.path.exists(config_file):
logging.warn("Could not find logging config file: %s", config_file)
else:
with open(config_file, 'r') as f:
loaded_config = json.load(f)
for key, val in loaded_config.items():
if key in config and val is None:
config[key] = val
# Set reasonable defaults for remaining Nones.
if config['log_filename'] is None:
config['log_filename'] = os.path.join(log_directory, log_filename)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment