commands
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user