This commit is contained in:
kiankyars 2025-11-26 19:00:55 -07:00 committed by GitHub
commit 3fc31e56ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -236,12 +236,15 @@ class Report:
os.makedirs(report_dir, exist_ok=True)
self.report_dir = report_dir
def log(self, section, data):
"""Log a section of data to the report."""
def log(self, section, data, append=False):
"""Log a section of data to the report. Set append=True to accumulate."""
slug = slugify(section)
file_name = f"{slug}.md"
file_path = os.path.join(self.report_dir, file_name)
with open(file_path, "w", encoding="utf-8") as f:
mode = "a" if append else "w"
with open(file_path, mode, encoding="utf-8") as f:
if append and os.path.exists(file_path) and os.path.getsize(file_path) > 0:
f.write("\n")
f.write(f"## {section}\n")
f.write(f"timestamp: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
for item in data: