Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow set debug_mode in runtime #1091 #1092

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)