refactor(logging): route frontend console calls through the logger

TRACES: | DR-204

484 ungated `console.*` calls across 63 non-test frontend files shipped to
end users with no way to turn them off. Mechanical substitution, no control
flow, error handling or message semantics changed:

  console.log / console.debug -> log.debug
  console.info                -> log.info
  console.warn                -> log.warn
  console.error               -> log.error

Hand-written `"[Scope] …"` prefixes are dropped where the logger's scope
now carries them; scope names that already existed are preserved verbatim
(`[Auth]`, `[VideoPlayer]`, `[PiP]`, …) and inferred from the filename
where a file had none. `src/routes/player/[id]/+page.svelte` keeps its
`NextEpisode` and `AutoPlay` sub-scopes as separate loggers rather than
flattening them into the page scope.

`grep -rn 'console\.' src/` now matches nothing outside the tests and the
facade itself.
This commit is contained in:
2026-08-20 19:29:59 +02:00
parent 4c82a0a025
commit d54d8cc7c4
63 changed files with 686 additions and 490 deletions
+11 -8
View File
@@ -17,6 +17,9 @@ import { writable, type Writable } from "svelte/store";
import { commands } from "$lib/api/bindings";
import { auth } from "$lib/stores/auth";
import { isConnected } from "$lib/stores/connectivity";
import { createLogger } from "$lib/utils/logger";
const log = createLogger("OfflineCatalog");
/**
* When true (and offline), library grids reveal greyed-out versions of media
@@ -58,7 +61,7 @@ async function pushCatalogVisibility(connected: boolean, showCatalog: boolean):
try {
await commands.setShowServerCatalog(include);
} catch (err) {
console.warn("[OfflineCatalog] Failed to set catalog visibility:", err);
log.warn("Failed to set catalog visibility:", err);
// The backend is still on the old gate, so forget that we sent this —
// otherwise the next identical transition is skipped as a no-op and the
// frontend and backend disagree about the filter for the rest of the
@@ -115,12 +118,12 @@ export async function syncCatalog(): Promise<void> {
syncInProgress = true;
try {
const result = await commands.syncFullCatalog(handle);
console.info(
`[OfflineCatalog] Synced ${result.itemsCached} items (${result.librariesFailed} libraries failed)`
log.info(
`Synced ${result.itemsCached} items (${result.librariesFailed} libraries failed)`
);
await refreshSyncStatus();
} catch (err) {
console.warn("[OfflineCatalog] Full catalog sync failed:", err);
log.warn("Full catalog sync failed:", err);
} finally {
syncInProgress = false;
}
@@ -136,12 +139,12 @@ export async function resumeQueued(): Promise<void> {
try {
const result = await commands.resumeQueuedDownloads(handle);
if (result.resolved > 0 || result.failed > 0) {
console.info(
`[OfflineCatalog] Resumed queued downloads: ${result.resolved} resolved, ${result.failed} failed`
log.info(
`Resumed queued downloads: ${result.resolved} resolved, ${result.failed} failed`
);
}
} catch (err) {
console.warn("[OfflineCatalog] Failed to resume queued downloads:", err);
log.warn("Failed to resume queued downloads:", err);
}
}
@@ -151,7 +154,7 @@ export async function refreshSyncStatus(): Promise<void> {
const status = await commands.catalogSyncStatus();
lastCatalogSync.set(status.lastSyncedAt ?? null);
} catch (err) {
console.debug("[OfflineCatalog] Failed to fetch sync status:", err);
log.debug("Failed to fetch sync status:", err);
}
}