island: Add function to setup default failsafe logger

This commit is contained in:
Mike Salvatore 2021-06-02 08:40:49 -04:00
parent 583115c419
commit 5e78666f91
2 changed files with 21 additions and 0 deletions

View File

@ -30,6 +30,15 @@ def setup_logging(data_dir_path, log_level):
_add_console_handler(logger, formatter)
def setup_default_failsafe_logging():
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
formatter = _get_log_formatter()
_add_console_handler(logger, formatter)
def _get_log_formatter():
return logging.Formatter(LOG_FORMAT)

View File

@ -87,3 +87,15 @@ def test_setup_logging_console_log_level_lower_case(capsys, tmpdir):
captured = capsys.readouterr()
assert TEST_STRING in captured.out
def test_setup_defailt_failsafe_logging(capsys):
TEST_STRING = "Hello, Monkey! (Console; Log level: debug)"
island_logger.setup_default_failsafe_logging()
logger = logging.getLogger("TestLogger")
logger.debug(TEST_STRING)
captured = capsys.readouterr()
assert TEST_STRING in captured.out
assert "DEBUG" in captured.out