diff --git a/monkey/monkey_island/cc/server_utils/island_logger.py b/monkey/monkey_island/cc/server_utils/island_logger.py index 2b4843876..826ddca78 100644 --- a/monkey/monkey_island/cc/server_utils/island_logger.py +++ b/monkey/monkey_island/cc/server_utils/island_logger.py @@ -2,10 +2,12 @@ import json import logging.config import os -__author__ = 'Maor.Rayzin' +__author__ = "Maor.Rayzin" -def json_setup_logging(default_path='logging.json', default_level=logging.INFO, env_key='LOG_CFG'): +def json_setup_logging( + default_path="logging.json", default_level=logging.INFO, env_key="LOG_CFG" +): """ Setup the logging configuration :param default_path: the default log configuration file path @@ -15,11 +17,13 @@ def json_setup_logging(default_path='logging.json', default_level=logging.INFO, """ path = default_path value = os.getenv(env_key, None) + if value: path = value + if os.path.exists(path): - with open(path, 'rt') as f: + with open(path, "rt") as f: config = json.load(f) - logging.config.dictConfig(config) + logging.config.dictConfig(config) else: logging.basicConfig(level=default_level)