This commit is contained in:
Talhadeveloperr
2026-09-09 18:07:19 +05:00
parent 3be641a36b
commit 1eed747639
53 changed files with 1213 additions and 56 deletions

View File

@@ -40,8 +40,19 @@ def log_info(message):
def _write(level, message):
global _log_path
if _log_path is None:
reset_log()
os.makedirs(LOGS_DIR, exist_ok=True)
_log_path = LOG_FILE
if not os.path.exists(_log_path):
# First-ever write with no prior reset_log() call in this
# process (e.g. a phase_N command run without a preceding
# clear_all): create the file fresh, but never truncate an
# existing log — separate process invocations of phase_1/2/3
# must all append to the same ongoing log.
with open(_log_path, "w", encoding="utf-8") as f:
f.write(f"Timetable generation log - started {datetime.datetime.now().isoformat()}\n")
f.write("=" * 80 + "\n")
line = f"[{datetime.datetime.now().strftime('%H:%M:%S')}] {level}: {message}"
with open(_log_path, "a", encoding="utf-8") as f:
f.write(line + "\n")