From 394ed67e28cadb1f8935a0a2731c34bac4cf4036 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Tue, 9 Jun 2026 22:12:05 -0600 Subject: [PATCH] feat(logging): expand debug-logging coverage, add primitives, redaction & tests Instrument the full download pipeline in the structured JSONL debug logger and make adding logging to new features a one-liner. Coverage: - DRM license request/response, content keys (incl. remote-CDM seam) and decrypt timing across Widevine/PlayReady/ClearKey - DASH/HLS/ISM manifest fetch + parse milestones (HLS.to_tracks also covers the m3u8_parser path used by iTunes/ATV-style services) - Per-backend vault get/add via the Vaults manager, track selection, subtitle conversion, repackage, normalize_vui, and full mkvmerge mux (command, duration, output size, warnings) - All external tooling (ffmpeg, ffprobe, mkvmerge, mkvpropedit, dovi_tool, SubtitleEdit, ccextractor) via a unified `tool_run` op, centralised in run_step/ffprobe + log_tool_run DX: - Add log_event() / timed_operation() primitives (no-op when disabled); retrofit ~91 guard/timing blocks onto them - Fix message= collision in log_drm_operation/log_vault_query/log_service_call that raised TypeError on the live decrypt path Redaction (redact_all = redact_text -> redact_url -> redact_path): - Collapse content/CDN/api URLs to `redacted[.ext]` - Strip local path prefixes (install root -> , venv -> , home -> ~) - Apply to every logged string so shared logs leak no URLs, paths or usernames - Drop per-request service_call logging (manifest parse is the request seam) --- docs/debug-logging.md | 76 ++++ tests/core/test_debug_logging.py | 338 +++++++++++++++++ unshackle/commands/dl.py | 265 +++++++------- unshackle/core/drm/clearkey.py | 16 + unshackle/core/drm/playready.py | 55 ++- unshackle/core/drm/widevine.py | 59 ++- unshackle/core/manifests/dash.py | 131 ++++--- unshackle/core/manifests/hls.py | 113 +++--- unshackle/core/manifests/ism.py | 128 ++++--- unshackle/core/proxies/gluetun.py | 421 ++++++++++------------ unshackle/core/tracks/dv_fixup.py | 31 +- unshackle/core/tracks/hybrid.py | 362 +++++++++---------- unshackle/core/tracks/subtitle.py | 45 ++- unshackle/core/tracks/subtitle_convert.py | 11 + unshackle/core/tracks/track.py | 21 +- unshackle/core/tracks/tracks.py | 119 +++--- unshackle/core/tracks/video.py | 46 ++- unshackle/core/utilities.py | 90 ++++- unshackle/core/utils/bitrate.py | 9 + unshackle/core/utils/dovi.py | 10 +- unshackle/core/utils/redact.py | 86 +++++ unshackle/core/utils/subprocess.py | 79 +++- unshackle/core/utils/tags.py | 11 + unshackle/core/vaults.py | 34 +- 24 files changed, 1763 insertions(+), 793 deletions(-) create mode 100644 docs/debug-logging.md create mode 100644 tests/core/test_debug_logging.py diff --git a/docs/debug-logging.md b/docs/debug-logging.md new file mode 100644 index 0000000..b8b6279 --- /dev/null +++ b/docs/debug-logging.md @@ -0,0 +1,76 @@ +# Structured debug logging + +unshackle emits structured JSON Lines (JSONL) when `-d`/`--debug` (a **global** flag, before the +subcommand: `unshackle -d dl ...`) or `config.debug` is set. Output lands at +`config.directories.logs / unshackle_debug__