From 287a76b03c36e3cd8458c7dc6e414fd71b8259fc Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Sun, 9 Apr 2023 10:04:03 +0100 Subject: [PATCH] add basic logging --- scripts/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/main.py b/scripts/main.py index 10f9d0dca..61d178d73 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -16,7 +16,15 @@ from ai_config import AIConfig import traceback import yaml import argparse +import logging +def configure_logging(): + logging.basicConfig(filename='log.txt', + filemode='a', + format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', + datefmt='%H:%M:%S', + level=logging.DEBUG) + return logging.getLogger('AutoGPT') def print_to_console( title, @@ -26,10 +34,12 @@ def print_to_console( min_typing_speed=0.05, max_typing_speed=0.01): global cfg + global logger if speak_text and cfg.speak_mode: speak.say_text(f"{title}. {content}") print(title_color + title + " " + Style.RESET_ALL, end="") if content: + logger.info(title + ': ' + content) if isinstance(content, list): content = " ".join(content) words = content.split() @@ -270,6 +280,7 @@ def parse_arguments(): # TODO: fill in llm values here cfg = Config() +logger = configure_logging() parse_arguments() ai_name = "" prompt = construct_prompt()