diff --git a/envs/monkey_zoo/blackbox/log_handlers/monkey_log_parser.py b/envs/monkey_zoo/blackbox/log_handlers/monkey_log_parser.py index ae0911431..44804a1fd 100644 --- a/envs/monkey_zoo/blackbox/log_handlers/monkey_log_parser.py +++ b/envs/monkey_zoo/blackbox/log_handlers/monkey_log_parser.py @@ -1,5 +1,8 @@ +import logging import re +LOGGER = logging.getLogger(__name__) + class MonkeyLogParser(object): @@ -14,11 +17,11 @@ class MonkeyLogParser(object): def print_errors(self): errors = MonkeyLogParser.get_errors(self.log_contents) if len(errors) > 0: - print("Found {} errors:".format(len(errors))) - for error_line in errors: - print(error_line) + LOGGER.info("Found {} errors:".format(len(errors))) + for index, error_line in enumerate(errors): + LOGGER.info("Err #{}: {}".format(index, error_line)) else: - print("No errors!") + LOGGER.info("No errors!") @staticmethod def get_errors(log_contents): @@ -28,11 +31,11 @@ class MonkeyLogParser(object): def print_warnings(self): warnings = MonkeyLogParser.get_warnings(self.log_contents) if len(warnings) > 0: - print("Found {} warnings:".format(len(warnings))) - for warning_line in warnings: - print(warning_line) + LOGGER.info("Found {} warnings:".format(len(warnings))) + for index, warning_line in enumerate(warnings): + LOGGER.info("Warn #{}: {}".format(index, warning_line)) else: - print("No warnings!") + LOGGER.info("No warnings!") @staticmethod def get_warnings(log_contents): diff --git a/envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py b/envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py index fb1c39ac2..b54f773e6 100644 --- a/envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py +++ b/envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py @@ -44,7 +44,7 @@ class TestLogsHandler(object): @staticmethod def parse_logs(log_paths): for log_path in log_paths: - print("Info from log at {}".format(log_path)) + LOGGER.info("Info from log at {}".format(log_path)) log_parser = MonkeyLogParser(log_path) log_parser.print_errors() log_parser.print_warnings() diff --git a/envs/monkey_zoo/blackbox/tests/basic_test.py b/envs/monkey_zoo/blackbox/tests/basic_test.py index f3ffb6566..086685925 100644 --- a/envs/monkey_zoo/blackbox/tests/basic_test.py +++ b/envs/monkey_zoo/blackbox/tests/basic_test.py @@ -78,12 +78,13 @@ class BasicTest(object): while not self.island_client.is_all_monkeys_dead() and time_passed < MAX_TIME_FOR_MONKEYS_TO_DIE: sleep(WAIT_TIME_BETWEEN_REQUESTS) time_passed += WAIT_TIME_BETWEEN_REQUESTS + LOGGER.debug("Waiting for all monkeys to die. Time passed: {}".format(time_passed)) if time_passed > MAX_TIME_FOR_MONKEYS_TO_DIE: LOGGER.error("Some monkeys didn't die after the test, failing") assert False def parse_logs(self): - LOGGER.info("\nParsing test logs:") + LOGGER.info("Parsing test logs:") self.log_handler.parse_test_logs() @staticmethod