refactor: implement structured logging across multiple modules
- Introduced logging functionality in cli.py, run_agent.py, scheduler.py, and various tool modules to replace print statements with structured logging. - Enhanced error handling and informational messages to improve debugging and monitoring capabilities. - Ensured consistent logging practices across the codebase, facilitating better traceability and maintenance.
This commit is contained in:
parent
b6247b71b5
commit
a885d2f240
14 changed files with 303 additions and 303 deletions
7
cli.py
7
cli.py
|
|
@ -12,6 +12,7 @@ Usage:
|
|||
python cli.py --list-tools # List available tools and exit
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
|
@ -21,6 +22,8 @@ from pathlib import Path
|
|||
from datetime import datetime
|
||||
from typing import List, Dict, Any, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Suppress startup messages for clean CLI experience
|
||||
os.environ["MSWEA_SILENT_STARTUP"] = "1" # mini-swe-agent
|
||||
os.environ["HERMES_QUIET"] = "1" # Our own modules
|
||||
|
|
@ -183,7 +186,7 @@ def load_cli_config() -> Dict[str, Any]:
|
|||
if "max_turns" in file_config and "agent" not in file_config:
|
||||
defaults["agent"]["max_turns"] = file_config["max_turns"]
|
||||
except Exception as e:
|
||||
print(f"[Warning] Failed to load cli-config.yaml: {e}")
|
||||
logger.warning("Failed to load cli-config.yaml: %s", e)
|
||||
|
||||
# Apply terminal config to environment variables (so terminal_tool picks them up)
|
||||
terminal_config = defaults.get("terminal", {})
|
||||
|
|
@ -646,7 +649,7 @@ def save_config_value(key_path: str, value: any) -> bool:
|
|||
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"(x_x) Failed to save config: {e}")
|
||||
logger.error("Failed to save config: %s", e)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue