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
+8 -5
View File
@@ -8,6 +8,9 @@
import { commands } from '$lib/api/bindings';
import type { CacheConfig } from '$lib/api/bindings';
import { auth } from '$lib/stores/auth';
import { createLogger } from '$lib/utils/logger';
const log = createLogger('Preload');
interface PreloadOptions {
/** Enable debug logging */
@@ -28,17 +31,17 @@ export async function preloadUpcomingTracks(options: PreloadOptions = {}): Promi
const userId = overrideUserId || auth.getUserId();
if (!userId) {
if (debug) console.log('[Preload] No active user session, skipping preload');
if (debug) log.debug('No active user session, skipping preload');
return;
}
if (debug) console.log('[Preload] Triggering preload for user:', userId);
if (debug) log.debug('Triggering preload for user:', userId);
// downloadBasePath is currently unused in the backend
const result = await commands.playerPreloadUpcoming(userId, '/downloads');
if (debug) {
console.log('[Preload] Result:', {
log.debug('Result:', {
queued: result.queuedCount,
alreadyDownloaded: result.alreadyDownloaded,
skipped: result.skipped
@@ -47,12 +50,12 @@ export async function preloadUpcomingTracks(options: PreloadOptions = {}): Promi
// Log meaningful results
if (result.queuedCount > 0) {
console.log(`[Preload] Queued ${result.queuedCount} track(s) for background download`);
log.debug(`Queued ${result.queuedCount} track(s) for background download`);
}
} catch (error) {
// Fail silently - preloading is a background optimization
// Don't interrupt the user's playback experience
console.warn('[Preload] Failed to preload upcoming tracks:', error);
log.warn('Failed to preload upcoming tracks:', error);
}
}