From 08668f3eae0151079d2cb5383db1c02d90c28ba3 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 11 May 2021 13:40:58 -0400 Subject: [PATCH] island: Handle lower case log levels in server config --- .../monkey_island/cc/server_utils/island_logger.py | 2 +- .../cc/server_utils/test_island_logger.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/server_utils/island_logger.py b/monkey/monkey_island/cc/server_utils/island_logger.py index 1e8b9b86e..c05915bc8 100644 --- a/monkey/monkey_island/cc/server_utils/island_logger.py +++ b/monkey/monkey_island/cc/server_utils/island_logger.py @@ -48,6 +48,6 @@ def setup_logging(data_dir_path, log_level): logger_configuration["handlers"]["file_handler"]["filename"] = os.path.join( data_dir_path, ISLAND_LOG_FILENAME ) - logger_configuration["root"]["level"] = log_level + logger_configuration["root"]["level"] = log_level.upper() logging.config.dictConfig(logger_configuration) diff --git a/monkey/tests/monkey_island/cc/server_utils/test_island_logger.py b/monkey/tests/monkey_island/cc/server_utils/test_island_logger.py index c301f3d5b..9f4e59af8 100644 --- a/monkey/tests/monkey_island/cc/server_utils/test_island_logger.py +++ b/monkey/tests/monkey_island/cc/server_utils/test_island_logger.py @@ -64,3 +64,17 @@ def test_setup_logging_console_log_level_info(capsys, tmpdir): captured = capsys.readouterr() assert TEST_STRING not in captured.out + + +def test_setup_logging_console_log_level_lower_case(capsys, tmpdir): + DATA_DIR = tmpdir + LOG_LEVEL = "debug" + TEST_STRING = "Hello, Monkey! (Console; Log level: debug)" + + setup_logging(DATA_DIR, LOG_LEVEL) + + logger = logging.getLogger("TestLogger") + logger.debug(TEST_STRING) + + captured = capsys.readouterr() + assert TEST_STRING in captured.out