forked from p15670423/monkey
island: Add function to setup default failsafe logger
This commit is contained in:
parent
583115c419
commit
5e78666f91
|
@ -30,6 +30,15 @@ def setup_logging(data_dir_path, log_level):
|
||||||
_add_console_handler(logger, formatter)
|
_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():
|
def _get_log_formatter():
|
||||||
return logging.Formatter(LOG_FORMAT)
|
return logging.Formatter(LOG_FORMAT)
|
||||||
|
|
||||||
|
|
|
@ -87,3 +87,15 @@ def test_setup_logging_console_log_level_lower_case(capsys, tmpdir):
|
||||||
|
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert TEST_STRING in captured.out
|
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
|
||||||
|
|
Loading…
Reference in New Issue