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:
@@ -18,6 +18,10 @@
|
||||
* Unsupported (no-op) on every non-Android platform.
|
||||
*/
|
||||
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("BgAudio");
|
||||
|
||||
interface AndroidBackgroundAudioBridge {
|
||||
setEnabled(enabled: boolean): void;
|
||||
}
|
||||
@@ -44,15 +48,15 @@ export function setBackgroundAudioEnabled(enabled: boolean): boolean {
|
||||
// before/without the bridge existing. Silently no-oping here leaves the UI
|
||||
// showing "armed" while native never learns — and the handoff then never
|
||||
// fires on lock. Report it so callers can retry.
|
||||
console.warn("[BgAudio] setEnabled: bridge missing, native NOT armed");
|
||||
log.warn("setEnabled: bridge missing, native NOT armed");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
b.setEnabled(enabled);
|
||||
console.log("[BgAudio] setEnabled ->", enabled);
|
||||
log.debug("setEnabled ->", enabled);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.warn("[BgAudio] Failed to set enabled:", err);
|
||||
log.warn("Failed to set enabled:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
* Provides tactile feedback for user actions
|
||||
*/
|
||||
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("Haptics");
|
||||
|
||||
type HapticStyle = "light" | "medium" | "heavy" | "success" | "warning" | "error";
|
||||
|
||||
/**
|
||||
@@ -28,7 +32,7 @@ export function haptic(style: HapticStyle = "medium") {
|
||||
navigator.vibrate(patterns[style]);
|
||||
} catch (error) {
|
||||
// Silently fail if vibration is not supported or blocked
|
||||
console.debug("Haptic feedback not available:", error);
|
||||
log.debug("Haptic feedback not available:", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* already does the right thing and these calls are no-ops.
|
||||
*/
|
||||
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("Immersive");
|
||||
|
||||
interface AndroidImmersiveBridge {
|
||||
enter(): void;
|
||||
exit(): void;
|
||||
@@ -38,7 +42,7 @@ export function isImmersiveSupported(): boolean {
|
||||
try {
|
||||
return bridge()?.isSupported() ?? false;
|
||||
} catch (err) {
|
||||
console.warn("[Immersive] isSupported check failed:", err);
|
||||
log.warn("isSupported check failed:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +52,7 @@ export function enterImmersive(): void {
|
||||
try {
|
||||
bridge()?.enter();
|
||||
} catch (err) {
|
||||
console.error("[Immersive] Failed to hide the system bars:", err);
|
||||
log.error("Failed to hide the system bars:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +67,6 @@ export function exitImmersive(): void {
|
||||
try {
|
||||
bridge()?.exit();
|
||||
} catch (err) {
|
||||
console.error("[Immersive] Failed to restore the system bars:", err);
|
||||
log.error("Failed to restore the system bars:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
* so there is no HTML5 fallback to reach for.
|
||||
*/
|
||||
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("PiP");
|
||||
|
||||
interface AndroidPictureInPictureBridge {
|
||||
enterPip(): void;
|
||||
isSupported(): boolean;
|
||||
@@ -41,7 +45,7 @@ export function isPipSupported(): boolean {
|
||||
try {
|
||||
return bridge()?.isSupported() ?? false;
|
||||
} catch (err) {
|
||||
console.warn("[PiP] isSupported check failed:", err);
|
||||
log.warn("isSupported check failed:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +58,7 @@ export function canEnterPip(): boolean {
|
||||
try {
|
||||
return bridge()?.canEnterPip() ?? false;
|
||||
} catch (err) {
|
||||
console.warn("[PiP] canEnterPip check failed:", err);
|
||||
log.warn("canEnterPip check failed:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +68,7 @@ export function enterPip(): void {
|
||||
try {
|
||||
bridge()?.enterPip();
|
||||
} catch (err) {
|
||||
console.error("[PiP] Failed to enter picture-in-picture:", err);
|
||||
log.error("Failed to enter picture-in-picture:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +86,7 @@ export function setAutoEnterEnabled(enabled: boolean): void {
|
||||
try {
|
||||
bridge()?.setAutoEnterEnabled(enabled);
|
||||
} catch (err) {
|
||||
console.warn("[PiP] Failed to set auto-enter:", err);
|
||||
log.warn("Failed to set auto-enter:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +119,6 @@ export function setHtml5VideoState(
|
||||
try {
|
||||
bridge()?.setHtml5VideoState(active, Math.round(width), Math.round(height), playing);
|
||||
} catch (err) {
|
||||
console.warn("[PiP] Failed to report HTML5 video state:", err);
|
||||
log.warn("Failed to report HTML5 video state:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
* document exists, and a page load wipes any inline style native had set.
|
||||
*/
|
||||
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("SafeArea");
|
||||
|
||||
/** Window insets in CSS pixels, one per edge. */
|
||||
export interface SafeAreaInsets {
|
||||
top: number;
|
||||
@@ -135,7 +139,7 @@ export function readNativeInsets(): SafeAreaInsets | null {
|
||||
try {
|
||||
return parseNativeInsets(bridge.get());
|
||||
} catch (err) {
|
||||
console.warn("[SafeArea] AndroidInsets bridge unusable:", err);
|
||||
log.warn("AndroidInsets bridge unusable:", err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
*/
|
||||
|
||||
import { nativeVideoActive } from "$lib/stores/nativeVideo";
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger("videoSurface");
|
||||
|
||||
interface AndroidVideoSurfaceBridge {
|
||||
setTransparent(transparent: boolean): void;
|
||||
@@ -50,7 +53,7 @@ export function isNativeSurfaceBridgeAvailable(): boolean {
|
||||
try {
|
||||
return bridge()?.isSupported() ?? false;
|
||||
} catch (err) {
|
||||
console.warn("[videoSurface] isSupported check failed:", err);
|
||||
log.warn("isSupported check failed:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,17 +76,17 @@ export function enableNativeVideoCompositing(): void {
|
||||
// correctly behind a WebView that never stopped painting its own opaque
|
||||
// background. That ambiguity is what DR-172 was left holding. MainActivity's
|
||||
// console bridge forwards this to logcat under the JellyTauWeb tag.
|
||||
console.error(
|
||||
"[videoSurface] AndroidVideoSurface bridge is MISSING - the webview will " +
|
||||
log.error(
|
||||
"AndroidVideoSurface bridge is MISSING - the webview will " +
|
||||
"stay opaque and native video will play as audio with no picture"
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
androidVideoSurface.setTransparent(true);
|
||||
console.log("[videoSurface] compositing enabled (setTransparent(true) sent)");
|
||||
log.debug("compositing enabled (setTransparent(true) sent)");
|
||||
} catch (err) {
|
||||
console.warn("[videoSurface] setTransparent(true) failed:", err);
|
||||
log.warn("setTransparent(true) failed:", err);
|
||||
nativeVideoActive.set(false);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +96,7 @@ export function disableNativeVideoCompositing(): void {
|
||||
try {
|
||||
bridge()?.setTransparent(false);
|
||||
} catch (err) {
|
||||
console.warn("[videoSurface] setTransparent(false) failed:", err);
|
||||
log.warn("setTransparent(false) failed:", err);
|
||||
}
|
||||
// Always clear the page layer, even if the bridge call failed, so the app is
|
||||
// never left rendering over a transparent window.
|
||||
|
||||
Reference in New Issue
Block a user