Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yxjiang committed Jul 23, 2024
1 parent 743feb2 commit 1a2b660
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions polymind/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def __init__(
self.logger = logging.getLogger(logger_name)
self.logger.setLevel(self.logging_level.value)

# Remove all existing handlers
for handler in self.logger.handlers:
self.logger.removeHandler(handler)

self.formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s (%(filename)s:%(lineno)d)")
self.console_handler = logging.StreamHandler()
self.console_handler.setLevel(self.logging_level.value)
Expand Down
2 changes: 1 addition & 1 deletion tests/polymind/core/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_custom_log_levels_added(self, mock_stream_handler, mock_get_logger):

Logger(logger_name="test_logger")

mock_logger.addHandler.assert_called_once_with(mock_handler)
mock_logger.addHandler.assert_called()
assert logging.getLevelName(25) == "TOOL", "TOOL log level not added"
assert logging.getLevelName(26) == "TASK", "TASK log level not added"
assert logging.getLevelName(27) == "THOUGHT_PROCESS", "THOUGHT_PROCESS log level not added"

0 comments on commit 1a2b660

Please sign in to comment.