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
+13 -10
View File
@@ -7,6 +7,9 @@ import type { Library, MediaItem, SearchResult, Genre } from "$lib/api/types";
import type { SearchOptions } from "$lib/api/bindings";
import type { SearchScope } from "$lib/utils/searchScope";
import { auth } from "./auth";
import { createLogger } from "$lib/utils/logger";
const log = createLogger("LibraryStore");
/**
* Payload of the backend `search-event` (mirrors Rust `SearchUpdateEvent`).
@@ -84,16 +87,16 @@ function createLibraryStore() {
const startTime = performance.now();
const repo = auth.getRepository();
console.log("📚 [LibraryStore] Loading libraries...");
log.debug("📚 Loading libraries...");
const libraries = await repo.getLibraries();
const loadTime = Math.round(performance.now() - startTime);
if (loadTime < 100) {
console.log(`🚀 [LibraryStore] CACHE HIT! Loaded ${libraries.length} libraries in ${loadTime}ms (instant)`);
log.debug(`🚀 CACHE HIT! Loaded ${libraries.length} libraries in ${loadTime}ms (instant)`);
} else {
console.log(` [LibraryStore] Loaded ${libraries.length} libraries in ${loadTime}ms (from server)`);
log.debug(`⏳ Loaded ${libraries.length} libraries in ${loadTime}ms (from server)`);
}
update((s) => ({
@@ -120,7 +123,7 @@ function createLibraryStore() {
const startTime = performance.now();
const repo = auth.getRepository();
console.log(`📚 [LibraryStore] Loading items for parent: ${parentId.substring(0, 8)}...`);
log.debug(`📚 Loading items for parent: ${parentId.substring(0, 8)}...`);
const result = await repo.getItems(parentId, {
startIndex: options.startIndex ?? 0,
@@ -134,9 +137,9 @@ function createLibraryStore() {
const loadTime = Math.round(performance.now() - startTime);
if (loadTime < 100) {
console.log(`🚀 [LibraryStore] CACHE HIT! Loaded ${result.items.length} items in ${loadTime}ms (instant)`);
log.debug(`🚀 CACHE HIT! Loaded ${result.items.length} items in ${loadTime}ms (instant)`);
} else {
console.log(` [LibraryStore] Loaded ${result.items.length} items in ${loadTime}ms (from server)`);
log.debug(`⏳ Loaded ${result.items.length} items in ${loadTime}ms (from server)`);
}
update((s) => ({
@@ -202,11 +205,11 @@ function createLibraryStore() {
const repo = auth.getRepository();
const item = await repo.getItem(itemId);
console.log(`[LibraryStore] loadItem(${itemId}): ${item.name} (${item.kind})`);
console.log(`[LibraryStore] - Has people? ${item.people ? `YES (${item.people.length})` : 'NO'}`);
log.debug(`loadItem(${itemId}): ${item.name} (${item.kind})`);
log.debug(`- Has people? ${item.people ? `YES (${item.people.length})` : 'NO'}`);
if (item.people && item.people.length > 0) {
item.people.forEach((p, i) => {
console.log(`[LibraryStore] [${i}] ${p.name} (type: "${p.type}", id: "${p.id}")`);
log.debug(` [${i}] ${p.name} (type: "${p.type}", id: "${p.id}")`);
});
}
@@ -319,7 +322,7 @@ function createLibraryStore() {
update((s) => ({ ...s, genres }));
return genres;
} catch (error) {
console.error("Failed to load genres:", error);
log.error("Failed to load genres:", error);
return [];
}
}