import json
import os

LOG_FILE = "full_cycle_log.json"

def append_log(record):
    if not os.path.exists(LOG_FILE):
        with open(LOG_FILE, "w", encoding="utf8") as f:
            json.dump([record], f, indent=2)
        return

    try:
        with open(LOG_FILE, "r", encoding="utf8") as f:
            data = json.load(f)
    except:
        data = []

    data.append(record)

    with open(LOG_FILE, "w", encoding="utf8") as f:
        json.dump(data, f, indent=2)
