# ./agent_logging.py # The Logger - Ensures that all agent actions, observations, and errors are logged to a localized log file for traceability and debugging purposes. import os from datetime import datetime def log_agent_action(action_type, message): """Logs all agent actions, observations, and errors to a localized log file.""" output_dir = "outputs" if not os.path.exists(output_dir): os.makedirs(output_dir) log_path = os.path.join(output_dir, "agent.log") timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(log_path, "a", encoding="utf-8") as log_file: log_file.write(f"[{timestamp}] [{action_type.upper()}] {message}\n")