Skip to content

Commit

Permalink
Merge branch 'master' into sized
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B authored Oct 16, 2024
2 parents 2b87ee1 + cbfc30e commit b097a6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion spinn_utilities/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
5 changes: 2 additions & 3 deletions spinn_utilities/log_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -37,15 +37,14 @@ 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`.
:param int min_level:
Constraint on the minimum logging level to retrieve.
:return:
A list of messages that satisfy the constraint.
:rtype: list(tuple(int, str))
"""
raise NotImplementedError

Expand Down
11 changes: 5 additions & 6 deletions unittests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b097a6b

Please sign in to comment.