add env var for where to store logs
This commit is contained in:
parent
a0ce60c070
commit
dbf89928ec
@ -23,12 +23,18 @@ SHOULD_MOCK_AI_RESPONSE = False
|
|||||||
|
|
||||||
|
|
||||||
def write_logs(prompt_messages, completion):
|
def write_logs(prompt_messages, completion):
|
||||||
# Create run_logs directory if it doesn't exist
|
# Get the logs path from environment, default to the current working directory
|
||||||
if not os.path.exists("run_logs"):
|
logs_path = os.environ.get("LOGS_PATH", os.getcwd())
|
||||||
os.makedirs("run_logs")
|
|
||||||
|
|
||||||
# Generate a unique filename using the current timestamp
|
# Create run_logs directory if it doesn't exist within the specified logs path
|
||||||
filename = datetime.now().strftime("run_logs/messages_%Y%m%d_%H%M%S.json")
|
logs_directory = os.path.join(logs_path, "run_logs")
|
||||||
|
if not os.path.exists(logs_directory):
|
||||||
|
os.makedirs(logs_directory)
|
||||||
|
|
||||||
|
print("Writing to logs directory:", logs_directory)
|
||||||
|
|
||||||
|
# Generate a unique filename using the current timestamp within the logs directory
|
||||||
|
filename = datetime.now().strftime(f"{logs_directory}/messages_%Y%m%d_%H%M%S.json")
|
||||||
|
|
||||||
# Write the messages dict into a new file for each run
|
# Write the messages dict into a new file for each run
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user