From 8c8f828b5989308ce5fd4ed62f11a58a3e288e26 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 15 Feb 2026 19:15:12 -0800 Subject: [PATCH] fix(mpv): gate socket logs by debug level - Gate MPV socket reconnect-attempt, close, and error logs behind SUBMINER_LOG_LEVEL=debug.\n- Preserve MPV reconnect behavior and success-path logging unaffected.\n- Update TASK-33 metadata/status with implementation summary. --- ...nnection-logs-to-debug-mode-in-Electron.md | 9 ++++++++- src/core/services/mpv-service.ts | 20 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/backlog/tasks/task-33 - Restrict-mpv-socket-connection-logs-to-debug-mode-in-Electron.md b/backlog/tasks/task-33 - Restrict-mpv-socket-connection-logs-to-debug-mode-in-Electron.md index f252404..a20b52a 100644 --- a/backlog/tasks/task-33 - Restrict-mpv-socket-connection-logs-to-debug-mode-in-Electron.md +++ b/backlog/tasks/task-33 - Restrict-mpv-socket-connection-logs-to-debug-mode-in-Electron.md @@ -1,9 +1,10 @@ --- id: TASK-33 title: Restrict mpv socket connection logs to debug mode in Electron -status: To Do +status: Done assignee: [] created_date: '2026-02-13 19:39' +updated_date: '2026-02-16 03:05' labels: - electron - logging @@ -30,6 +31,12 @@ In normal operation, Electron should not spam logs while waiting for mpv socket - [ ] #6 If connection fails and retries continue, keep a debug-only or final-error log policy consistent with existing logging severity conventions. +## Final Summary + + +Implemented debug-gated MPV socket noise suppression in normal mode while preserving reconnect behavior. Added an internal check for SUBMINER_LOG_LEVEL==='debug' and wrapped socket reconnect-attempt, close, and error logs so regular startup/reconnect loops no longer emit per-interval messages unless debug logging is enabled. Kept existing connection-success flow unchanged. Validation: `pnpm run build`, `node --test dist/core/services/mpv-service.test.js`. + + ## Definition of Done - [ ] #1 No connection-attempt/connect-wait logs are produced in non-debug mode. diff --git a/src/core/services/mpv-service.ts b/src/core/services/mpv-service.ts index 64533a0..c5edca4 100644 --- a/src/core/services/mpv-service.ts +++ b/src/core/services/mpv-service.ts @@ -19,6 +19,10 @@ import { } from "./mpv-transport"; import { resolveCurrentAudioStreamIndex } from "./mpv-state"; +const isDebugLoggingEnabled = (): boolean => { + return (process.env.SUBMINER_LOG_LEVEL || "").toLowerCase() === "debug"; +}; + export { MPV_REQUEST_ID_SECONDARY_SUB_VISIBILITY, } from "./mpv-protocol"; @@ -129,11 +133,15 @@ export class MpvIpcClient implements MpvClient { this.processBuffer(); }, onError: (err: Error) => { - console.error("MPV socket error:", err.message); + if (isDebugLoggingEnabled()) { + console.error("MPV socket error:", err.message); + } this.failPendingRequests(); }, onClose: () => { - console.log("MPV socket closed"); + if (isDebugLoggingEnabled()) { + console.log("MPV socket closed"); + } this.connected = false; this.connecting = false; this.socket = null; @@ -194,9 +202,11 @@ export class MpvIpcClient implements MpvClient { getReconnectTimer: () => this.deps.getReconnectTimer(), setReconnectTimer: (timer) => this.deps.setReconnectTimer(timer), onReconnectAttempt: (attempt, delay) => { - console.log( - `Attempting to reconnect to MPV (attempt ${attempt}, delay ${delay}ms)...`, - ); + if (isDebugLoggingEnabled()) { + console.log( + `Attempting to reconnect to MPV (attempt ${attempt}, delay ${delay}ms)...`, + ); + } }, connect: () => { this.connect();