mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-14 02:16:21 +00:00
Avoid log level misconfiguration, allow user to configure log level
This commit is contained in:
1 parent
d32d74a477
commit
927e36bbb6
3 files changed
+12
-4
No files matched your search
@@ -6,3 +6,5 @@ language: python
|
||||
ignored_dirs: [".git", "temp"]
|
||||
# whether to open a graphical window with Serena's logs (not supported on MacOS)
|
||||
gui_log_window: True
|
||||
# minimum log level for the GUI log window (10 = debug, 20 = info, 30 = warning, 40 = error)
|
||||
gui_log_level: 20
|
||||
@@ -12,8 +12,11 @@ from sensai.util.helper import mark_used
|
||||
from serena.agent import SerenaAgent
|
||||
from serena.agno import SerenaAgnoToolkit
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
mark_used(Gemini, Claude)
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
Logger.root.setLevel(logging.INFO)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
project_file_path = "../myproject.yml"
|
||||
@@ -38,5 +41,4 @@ agno_agent = Agent(
|
||||
app = Playground(agents=[agno_agent]).get_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
Logger.root.setLevel(logging.INFO)
|
||||
serve_playground_app("agno_agent:app", reload=False)
|
||||
+6
-2
@@ -8,6 +8,7 @@ import os
|
||||
import platform
|
||||
import sys
|
||||
import traceback
|
||||
import warnings
|
||||
from abc import ABC
|
||||
from collections import defaultdict
|
||||
from collections.abc import Callable, Iterator
|
||||
@@ -32,7 +33,6 @@ from serena.util.shell import execute_shell_command
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
LOG_FORMAT = "%(levelname)-5s %(asctime)-15s %(name)s:%(funcName)s:%(lineno)d - %(message)s"
|
||||
LOG_LEVEL = logging.INFO
|
||||
TTool = TypeVar("TTool", bound="Tool")
|
||||
|
||||
|
||||
@@ -63,7 +63,11 @@ class SerenaAgent:
|
||||
if platform.system() == "Darwin":
|
||||
log.warning("GUI log window is not supported on macOS")
|
||||
else:
|
||||
self._gui_log_handler = GuiLogViewerHandler(GuiLogViewer(title="Serena Logs"), level=LOG_LEVEL, format_string=LOG_FORMAT)
|
||||
log_level = project_config.get("gui_log_level", logging.INFO)
|
||||
if Logger.root.level > log_level:
|
||||
warnings.warn(f"Root logger level is higher than GUI log level; changing the root logger level to {log_level}")
|
||||
Logger.root.setLevel(log_level)
|
||||
self._gui_log_handler = GuiLogViewerHandler(GuiLogViewer(title="Serena Logs"), level=log_level, format_string=LOG_FORMAT)
|
||||
Logger.root.addHandler(self._gui_log_handler)
|
||||
|
||||
log.info(
|
||||
|
||||
Reference in new issue
Block a user