Mirror download job logs to stdout
This commit is contained in:
@@ -29,6 +29,7 @@ from app_support import (
|
||||
finalize_library_files,
|
||||
job_output_dir,
|
||||
job_staging_dir,
|
||||
job_stdout_enabled,
|
||||
load_json,
|
||||
normalize_config,
|
||||
now_iso,
|
||||
@@ -1434,6 +1435,7 @@ class DownloadQueue:
|
||||
text = strip_control(line).strip()
|
||||
if not text:
|
||||
return
|
||||
self._stdout_log(job, text)
|
||||
with self.lock:
|
||||
job.setdefault("log", []).append(text)
|
||||
job["log"] = job["log"][-MAX_LOG_LINES:]
|
||||
@@ -1447,6 +1449,16 @@ class DownloadQueue:
|
||||
if should_flush:
|
||||
self._save_job_locked(job)
|
||||
|
||||
def _stdout_log(self, job, line):
|
||||
if not job_stdout_enabled():
|
||||
return
|
||||
text = strip_control(str(line)).strip()
|
||||
if not text:
|
||||
return
|
||||
job_id = str((job or {}).get("id") or "-")
|
||||
backend = str((job or {}).get("download_backend") or "download")
|
||||
print(f"[download:{job_id}:{backend}] {text}", flush=True)
|
||||
|
||||
def _cleanup_staging_dir(self, job):
|
||||
staging_dir = job_staging_dir(job)
|
||||
if not staging_dir.exists():
|
||||
|
||||
Reference in New Issue
Block a user