Add module logger + surface silent exceptions in 7 logger-less files — 12 sites

These files had silent `except Exception: pass` blocks but no module
logger. Added `import logging` + `logger = logging.getLogger(__name__)`
at the top of each, then replaced the silent excepts with
`logger.debug(...)`.

- core/replaygain.py — 4 sites (id3 txxx + vorbis + mp4 atom reads)
- core/wishlist/presence.py — 3 sites (wishlist row parsing + queries)
- core/runtime_state.py — 1 site (activity toast emit)
- core/automation/signals.py — 1 site (collect known signals)
- core/download_engine/rate_limit.py — 1 site (plugin rate_limit_policy)
- api/system.py — 1 site (hydrabase status probe)
- api/search.py — 1 site (hydrabase search)

Refs #369
pull/516/head
Broque Thomas 1 week ago
parent 8dc9f79f97
commit 8219771304

@ -2,10 +2,14 @@
Search endpoints search external sources (Spotify, iTunes, Hydrabase).
"""
import logging
from flask import request, current_app
from .auth import require_api_key
from .helpers import api_success, api_error
logger = logging.getLogger(__name__)
def register_routes(bp):
@ -38,8 +42,8 @@ def register_routes(bp):
if hydra_results:
tracks = [_serialize_track(t) for t in hydra_results]
return api_success({"tracks": tracks, "source": "hydrabase"})
except Exception:
pass
except Exception as e:
logger.debug("hydrabase search failed: %s", e)
spotify = ctx.get("spotify_client")
from core.metadata_service import get_primary_source, get_primary_client

@ -2,12 +2,15 @@
System endpoints status, activity feed, stats.
"""
import logging
import time
from flask import current_app
from .auth import require_api_key
from .helpers import api_success, api_error
logger = logging.getLogger(__name__)
def register_routes(bp):
@ -35,8 +38,8 @@ def register_routes(bp):
try:
ws, _ = hydrabase.get_ws_and_lock()
hydrabase_ok = ws is not None and ws.connected
except Exception:
pass
except Exception as e:
logger.debug("hydrabase status probe failed: %s", e)
return api_success({
"uptime": f"{hours}h {minutes}m {seconds}s",

@ -8,6 +8,9 @@ names from the saved automation set so the builder UI can autocomplete.
from __future__ import annotations
import json
import logging
logger = logging.getLogger(__name__)
def collect_known_signals(database) -> list[str]:
@ -38,6 +41,6 @@ def collect_known_signals(database) -> list[str]:
signals.add(sig)
except (json.JSONDecodeError, TypeError):
pass
except Exception:
pass
except Exception as e:
logger.debug("collect known signals failed: %s", e)
return sorted(signals)

@ -22,8 +22,11 @@ module-level constant in the client file.
from __future__ import annotations
import logging
from dataclasses import dataclass
logger = logging.getLogger(__name__)
@dataclass(frozen=True)
class RateLimitPolicy:
@ -63,8 +66,8 @@ def resolve_policy(plugin) -> RateLimitPolicy:
policy = method()
if isinstance(policy, RateLimitPolicy):
return policy
except Exception:
pass
except Exception as e:
logger.debug("plugin rate_limit_policy() call failed: %s", e)
declared = getattr(plugin, 'RATE_LIMIT_POLICY', None)
if isinstance(declared, RateLimitPolicy):

@ -7,10 +7,13 @@ Tag writing uses mutagen directly to stay consistent with the rest of the codeba
Supported formats: MP3, FLAC, OGG Vorbis, Opus, M4A/MP4
"""
import logging
import re
import subprocess
from typing import Optional, Tuple, Dict
logger = logging.getLogger(__name__)
# ReplayGain 2.0 reference level (EBU R128)
RG_REFERENCE_LUFS = -18.0
@ -189,8 +192,8 @@ def read_replaygain_tags(file_path: str) -> Dict[str, Optional[str]]:
result['track_peak'] = _mp4_rg(audio, _TAG_TRACK_PEAK)
result['album_gain'] = _mp4_rg(audio, _TAG_ALBUM_GAIN)
result['album_peak'] = _mp4_rg(audio, _TAG_ALBUM_PEAK)
except Exception:
pass
except Exception as e:
logger.debug("read replaygain tags failed: %s", e)
return result
@ -207,8 +210,8 @@ def _read_id3_txxx(audio, description: str) -> Optional[str]:
if frame_key.upper() == key.upper():
frame = audio.tags[frame_key]
return str(frame.text[0]) if frame.text else None
except Exception:
pass
except Exception as e:
logger.debug("read id3 txxx frame failed: %s", e)
return None
@ -218,8 +221,8 @@ def _vorbis_first(audio, key: str) -> Optional[str]:
vals = audio.get(key) or audio.get(key.upper())
if vals:
return str(vals[0])
except Exception:
pass
except Exception as e:
logger.debug("read vorbis comment failed: %s", e)
return None
@ -234,8 +237,8 @@ def _mp4_rg(audio, tag_name: str) -> Optional[str]:
if hasattr(val, 'decode'):
return val.decode('utf-8')
return str(val)
except Exception:
pass
except Exception as e:
logger.debug("read mp4 replaygain atom failed: %s", e)
return None

@ -2,11 +2,14 @@
from __future__ import annotations
import logging
import threading
import time
from functools import wraps
from typing import Any, Dict, Optional
logger = logging.getLogger(__name__)
matched_context_lock = threading.Lock()
matched_downloads_context: Dict[str, Dict[str, Any]] = {}
tasks_lock = threading.Lock()
@ -57,8 +60,8 @@ def add_activity_item(icon, title, subtitle, time_ago="Now", show_toast=True):
if show_toast and _activity_toast_emitter is not None:
try:
_activity_toast_emitter("dashboard:toast", activity_item)
except Exception:
pass
except Exception as e:
logger.debug("emit activity toast failed: %s", e)
return activity_item

@ -3,6 +3,9 @@
from __future__ import annotations
import json
import logging
logger = logging.getLogger(__name__)
def load_wishlist_keys(cursor, profile_id: int) -> set[str]:
@ -27,21 +30,21 @@ def load_wishlist_keys(cursor, profile_id: int) -> set[str]:
wa = ""
if wname:
keys.add(wname + "|||" + wa.lower().strip())
except Exception:
pass
except Exception as e:
logger.debug("parse wishlist row failed: %s", e)
try:
cursor.execute("SELECT spotify_data FROM wishlist_tracks WHERE profile_id = ?", (profile_id,))
_absorb(cursor.fetchall())
return keys
except Exception:
pass
except Exception as e:
logger.debug("profile-aware wishlist query failed: %s", e)
try:
cursor.execute("SELECT spotify_data FROM wishlist_tracks")
_absorb(cursor.fetchall())
except Exception:
pass
except Exception as e:
logger.debug("legacy wishlist query failed: %s", e)
return keys

Loading…
Cancel
Save