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:
@@ -11,6 +11,9 @@
|
||||
|
||||
import { commands } from "$lib/api/bindings";
|
||||
import { auth } from "$lib/stores/auth";
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("PlaybackReporting");
|
||||
|
||||
/**
|
||||
* Record the start of playback **locally**, with the context it started from.
|
||||
@@ -32,8 +35,8 @@ export async function reportPlaybackStart(
|
||||
const positionMs = Math.floor(positionSeconds * 1000);
|
||||
const userId = auth.getUserId();
|
||||
|
||||
console.log(
|
||||
"[PlaybackReporting] reportPlaybackStart - itemId:",
|
||||
log.debug(
|
||||
"reportPlaybackStart - itemId:",
|
||||
itemId,
|
||||
"positionSeconds:",
|
||||
positionSeconds,
|
||||
@@ -47,7 +50,7 @@ export async function reportPlaybackStart(
|
||||
try {
|
||||
await commands.storageUpdatePlaybackContext(userId, itemId, positionMs, contextType, contextId);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update playback context:", e);
|
||||
log.error("Failed to update playback context:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +79,7 @@ export async function reportPlaybackProgress(
|
||||
|
||||
// Reduce logging for frequent progress updates
|
||||
if (Math.floor(positionSeconds) % 30 === 0) {
|
||||
console.log("[PlaybackReporting] reportPlaybackProgress - itemId:", itemId, "position:", positionSeconds);
|
||||
log.debug("reportPlaybackProgress - itemId:", itemId, "position:", positionSeconds);
|
||||
}
|
||||
|
||||
// Update local DB only (progress updates are frequent, don't report to server)
|
||||
@@ -84,7 +87,7 @@ export async function reportPlaybackProgress(
|
||||
try {
|
||||
await commands.storageUpdatePlaybackProgress(userId, itemId, positionMs);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update local progress:", e);
|
||||
log.error("Failed to update local progress:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,14 +104,14 @@ export async function reportPlaybackStopped(itemId: string, positionSeconds: num
|
||||
const positionMs = Math.floor(positionSeconds * 1000);
|
||||
const userId = auth.getUserId();
|
||||
|
||||
console.log("[PlaybackReporting] reportPlaybackStopped - itemId:", itemId, "positionSeconds:", positionSeconds);
|
||||
log.debug("reportPlaybackStopped - itemId:", itemId, "positionSeconds:", positionSeconds);
|
||||
|
||||
// Update local DB first (always works, even offline)
|
||||
if (userId) {
|
||||
try {
|
||||
await commands.storageUpdatePlaybackProgress(userId, itemId, positionMs);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update local progress:", e);
|
||||
log.error("Failed to update local progress:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +123,7 @@ export async function reportPlaybackStopped(itemId: string, positionSeconds: num
|
||||
const repo = auth.getRepository();
|
||||
await repo.reportPlaybackStopped(itemId, positionMs);
|
||||
} catch (e) {
|
||||
console.warn("[PlaybackReporting] Stop-report did not reach the server; queued for sync:", e);
|
||||
log.warn("Stop-report did not reach the server; queued for sync:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,14 +136,14 @@ export async function reportPlaybackStopped(itemId: string, positionSeconds: num
|
||||
export async function markAsPlayed(itemId: string): Promise<void> {
|
||||
const userId = auth.getUserId();
|
||||
|
||||
console.log("[PlaybackReporting] markAsPlayed - itemId:", itemId);
|
||||
log.debug("markAsPlayed - itemId:", itemId);
|
||||
|
||||
// Update local DB first
|
||||
if (userId) {
|
||||
try {
|
||||
await commands.storageMarkPlayed(userId, itemId);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to mark as played in local DB:", e);
|
||||
log.error("Failed to mark as played in local DB:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +156,6 @@ export async function markAsPlayed(itemId: string): Promise<void> {
|
||||
await repo.reportPlaybackStopped(itemId, item.durationMs);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to report as played:", e);
|
||||
log.error("Failed to report as played:", e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user