import datetime LOG_FILE = "runtime.log" ERROR_FILE = "errors.log" def log(message: str, level: str = "INFO"): ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") line = f"[{ts}] [{level}] {message}" print(line) with open(LOG_FILE, "a", encoding="utf-8") as f: f.write(line + "\n") if level == "ERROR": with open(ERROR_FILE, "a", encoding="utf-8") as f: f.write(line + "\n")