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

Feature mute stream log for info level #1124

Merged
merged 3 commits into from
Apr 5, 2024
Merged
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
8 changes: 7 additions & 1 deletion metagpt/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

from metagpt.const import METAGPT_ROOT

_print_level = "INFO"
Copy link
Owner

@geekan geekan Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEBUG should be used for default _print_level?


def define_log_level(print_level="INFO", logfile_level="DEBUG", name: str = None):
"""Adjust the log level to above level"""
global _print_level
_print_level = print_level

current_date = datetime.now()
formatted_date = current_date.strftime("%Y%m%d")
log_name = f"{name}_{formatted_date}" if name else formatted_date # name a log with prefix name
Expand All @@ -39,4 +43,6 @@ def set_llm_stream_logfunc(func):
_llm_stream_log = func


_llm_stream_log = partial(print, end="")
def _llm_stream_log(msg):
if _print_level in ["DEBUG"]:
print(msg, end="")
Loading