Spaces:
Sleeping
Sleeping
| """Failed download logging.""" | |
| import logging | |
| from datetime import datetime | |
| from image_resizer.config import FAILED_LOG_PATH | |
| logger = logging.getLogger(__name__) | |
| def log_failure(url: str, reason: str) -> None: | |
| """Append a failed download entry to the log file.""" | |
| timestamp = datetime.now().isoformat(timespec="seconds") | |
| line = f"{timestamp}\t{url}\t{reason}\n" | |
| try: | |
| with open(FAILED_LOG_PATH, "a", encoding="utf-8") as f: | |
| f.write(line) | |
| except OSError as e: | |
| logger.error("Could not write to %s: %s", FAILED_LOG_PATH, e) | |