Skip to content

Commit

Permalink
Merge pull request #1092 from KevinZhang19870314/main
Browse files Browse the repository at this point in the history
feat: allow set debug_mode in runtime #1091
  • Loading branch information
ashpreetbedi authored Oct 3, 2024
2 parents 6cd5ce4 + 52929cf commit 8f81679
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion phi/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from phi.storage.assistant import AssistantStorage
from phi.utils.format_str import remove_indent
from phi.tools import Tool, Toolkit, Function
from phi.utils.log import logger, set_log_level_to_debug
from phi.utils.log import logger, set_log_level_to_debug, set_log_level_to_info
from phi.utils.message import get_text_from_message
from phi.utils.merge_dict import merge_dictionaries
from phi.utils.timer import Timer
Expand Down Expand Up @@ -209,6 +209,10 @@ def set_log_level(cls, v: bool) -> bool:
if v:
set_log_level_to_debug()
logger.debug("Debug logs enabled")
else:
set_log_level_to_info()
logger.info("Debug logs disabled")

return v

@field_validator("run_id", mode="before")
Expand Down
5 changes: 5 additions & 0 deletions phi/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ def get_logger(logger_name: str) -> logging.Logger:
def set_log_level_to_debug():
_logger = logging.getLogger(LOGGER_NAME)
_logger.setLevel(logging.DEBUG)


def set_log_level_to_info():
_logger = logging.getLogger(LOGGER_NAME)
_logger.setLevel(logging.INFO)

0 comments on commit 8f81679

Please sign in to comment.