From fa9f133ab11ba96dc0a417552b136facd9f3f7a3 Mon Sep 17 00:00:00 2001 From: Yx Jiang <2237303+yxjiang@users.noreply.github.com> Date: Sat, 15 Jun 2024 09:58:06 -0700 Subject: [PATCH 1/2] Update logger --- polymind/core/logger.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/polymind/core/logger.py b/polymind/core/logger.py index 2d891b2..0ee4841 100644 --- a/polymind/core/logger.py +++ b/polymind/core/logger.py @@ -2,7 +2,7 @@ import logging import os from enum import Enum -from typing import Any +from typing import Optional from colorama import Fore, ansi from dotenv import load_dotenv @@ -33,20 +33,26 @@ def __le__(self, other): def __gt__(self, other): return self.value > other.value + def __str__(self) -> str: + return self.name + + def __repr__(self) -> str: + return self.name + def __new__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance - def __init__(self, logger_name: str, verbose: bool = True, level: Any = logging.INFO): + def __init__(self, logger_name: str, verbose: bool = True, level: Optional[LoggingLevel] = None): if not hasattr(self, "logger"): load_dotenv(override=True) - self.logging_level = Logger.LoggingLevel[os.getenv("LOGGING_LEVEL", "TOOL")] + self.logging_level = level if level else Logger.LoggingLevel[os.getenv("LOGGING_LEVEL", "TOOL")] self.logger = logging.getLogger(logger_name) - self.logger.setLevel(level=level) + self.logger.setLevel(level=self.logging_level.value) self.formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s (%(filename)s:%(lineno)d)") self.console_handler = logging.StreamHandler() - self.console_handler.setLevel(level=level) + self.console_handler.setLevel(level=self.logging_level.value) self.console_handler.setFormatter(self.formatter) self.logger.addHandler(self.console_handler) From fa2e7740ffa1724fac0b7dfed78a35d9eb747d2c Mon Sep 17 00:00:00 2001 From: Yx Jiang <2237303+yxjiang@users.noreply.github.com> Date: Sat, 15 Jun 2024 10:01:01 -0700 Subject: [PATCH 2/2] Update logger --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1baeaa2..40db143 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "polymind" -version = "0.0.50" # Update this version before publishing to PyPI +version = "0.0.51" # Update this version before publishing to PyPI description = "PolyMind is a customizable collaborative multi-agent framework for collective intelligence and distributed problem solving." authors = ["TechTao"] license = "MIT License"