Skip to content

Commit 70f2f50

Browse files
kernoebclaude
andcommitted
chore(log): drop per-fetch HLS body log and cap log file at 5MB
The diagnostic body-head log on every successful HLS fetch fires once per variant playlist refresh (every 2-3 seconds during live playback) and was only useful for the unsafe-headers diagnosis — now resolved. Drop it; keep the HTTP non-2xx error log (rare) for ongoing visibility. Also configure plugin-log rotation: max 5 MB per file, keep only one archive (~10 MB total ceiling on disk). Without this the file grew unboundedly because plugin-log defaults to no rotation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1edc326 commit 70f2f50

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ pub fn run() {
442442
// platform's app log dir (macOS: ~/Library/Logs/<id>, Windows:
443443
// %LOCALAPPDATA%\<id>\logs, Linux: ~/.local/share/<id>/logs).
444444
.target(tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::LogDir { file_name: None }))
445+
// Cap log volume: rotate at 5 MB and keep only the previous
446+
// archive — long-running sessions otherwise grow the file
447+
// unboundedly (HLS variant playlists tick every few seconds).
448+
.max_file_size(5 * 1024 * 1024)
449+
.rotation_strategy(tauri_plugin_log::RotationStrategy::KeepOne)
445450
.build())
446451
.plugin(tauri_plugin_opener::init())
447452
.plugin(tauri_plugin_shell::init())

src/TauriHlsLoader.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,22 @@ export class TauriHlsLoader implements Loader<LoaderContext> {
7272

7373
if (!res.ok) {
7474
const body = await res.text().catch(() => '');
75-
const interestingHeaders = ['server', 'x-served-by', 'cf-ray', 'set-cookie', 'content-type', 'x-cache', 'twitch-edge-id'];
76-
const headerDump = interestingHeaders
77-
.map((h) => `${h}=${res.headers.get(h) ?? '-'}`)
78-
.join(' ');
79-
info(`[HlsLoader] HTTP ${res.status} on ${urlTail} | ${headerDump} | body=${body.slice(0, 100)}`);
75+
info(`[HlsLoader] HTTP ${res.status} on ${urlTail}: ${body.slice(0, 80)}`);
8076
this.callbacks?.onError(
81-
{ code: res.status, text: `HTTP ${res.status}: ${body.slice(0, 80)}` },
77+
{ code: res.status, text: `HTTP ${res.status}` },
8278
this.context,
8379
undefined,
8480
this.stats,
8581
);
8682
return;
8783
}
8884

89-
// Decode via TextDecoder rather than res.text() so we control the
90-
// encoding identically across platforms (some Tauri http plugin paths
91-
// returned latin1-decoded text on Windows under earlier diagnoses).
85+
// Decode via TextDecoder rather than res.text() so the encoding is
86+
// controlled identically across platforms.
9287
const buf = await res.arrayBuffer();
9388
const data: string | ArrayBuffer = isText ? new TextDecoder('utf-8').decode(buf) : buf;
9489
const size = isText ? (data as string).length : buf.byteLength;
9590

96-
if (isText) {
97-
const ctxType = (this.context as { type?: string }).type ?? 'unknown';
98-
const head = (data as string).slice(0, 80).replace(/\n/g, ' \\n ');
99-
info(`[HlsLoader] ${ctxType} ${size}B head="${head}"`);
100-
}
101-
10291
const now = performance.now();
10392
this.stats.loading.first ||= now;
10493
this.stats.loading.end = now;

0 commit comments

Comments
 (0)