From 4cb28db3bc0c4a7a28fccffb0aa08d22bf8354a1 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 10 Feb 2021 07:29:28 -0500 Subject: [PATCH] cc: reformat island_logger.py for readability 1. Adjusted some spacing and indentation 2. Reformatted with Black --- .../monkey_island/cc/server_utils/island_logger.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)