diff --git a/spinn_utilities/log.py b/spinn_utilities/log.py index 26684ada..44c86160 100644 --- a/spinn_utilities/log.py +++ b/spinn_utilities/log.py @@ -277,7 +277,8 @@ def atexit_handler(cls) -> None: except Exception: # pylint: disable=broad-except pass - messages.extend(cls._pop_not_stored_messages(cls.__repeat_at_end)) + messages.extend(map(lambda x: x[2], + cls._pop_not_stored_messages(cls.__repeat_at_end))) if messages: level = logging.getLevelName(cls.__repeat_at_end) print(f"\n!WARNING: {len(messages)} log messages were " diff --git a/spinn_utilities/log_store.py b/spinn_utilities/log_store.py index 557963ae..1d78e6ea 100644 --- a/spinn_utilities/log_store.py +++ b/spinn_utilities/log_store.py @@ -13,7 +13,7 @@ # limitations under the License. from datetime import datetime -from typing import List, Optional, Tuple +from typing import List, Optional from .abstract_base import abstractmethod @@ -37,7 +37,7 @@ def store_log(self, level: int, message: str, @abstractmethod def retreive_log_messages( - self, min_level: int = 0) -> List[Tuple[int, str]]: + self, min_level: int = 0) -> List[str]: """ Retrieves all log messages at or above the `min_level`. @@ -45,7 +45,6 @@ def retreive_log_messages( Constraint on the minimum logging level to retrieve. :return: A list of messages that satisfy the constraint. - :rtype: list(tuple(int, str)) """ raise NotImplementedError diff --git a/unittests/test_log.py b/unittests/test_log.py index 1b4bae1d..56e20333 100644 --- a/unittests/test_log.py +++ b/unittests/test_log.py @@ -14,7 +14,7 @@ from datetime import datetime import logging -from typing import List, Optional, Tuple +from typing import List, Optional from spinn_utilities.log import ( _BraceMessage, ConfiguredFilter, ConfiguredFormatter, FormatAdapter, LogLevelTooHighException) @@ -64,11 +64,11 @@ def store_log(self, level: int, message: str, @overrides(LogStore.retreive_log_messages) def retreive_log_messages( - self, min_level: int = 0) -> List[Tuple[int, str]]: + self, min_level: int = 0) -> List[str]: result = [] for (level, message) in self.data: if level >= min_level: - result.append((level, message)) + result.append(message) return result @overrides(LogStore.get_location) @@ -193,9 +193,8 @@ def test_log_store(): # an error disables the logstore for safety # includes the ones before setting the log assert store.retreive_log_messages() == \ - [(30, 'This is early'), (20, 'Pre info'), - (30, 'This is a warning'), (40, 'And an Error'), - (20, 'This is an info')] + ['This is early', 'Pre info', 'This is a warning', 'And an Error', + 'This is an info'] assert 3 == len(store.retreive_log_messages(logging.WARNING)) # Only the ones from after the log store turned off