Add logging system: app.log + matching.log with admin viewer
- Backend: RotatingFileHandler for app.log (all) and matching.log (matcher/matching services)
- New GET/DELETE /api/logs/{app|matching} endpoints (admin-only)
- matcher.py: improved cover-download logging (URL, bytes, HTTP errors, missing cover URL)
- Frontend: Logs tab in Admin panel with log switcher, line count selector, color-coded ERROR/WARNING lines, clear button
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,7 @@ async def _download_cover(url: str, item_id: str) -> str | None:
|
||||
if ".png" in url:
|
||||
ext = ".png"
|
||||
dest = os.path.join(settings.covers_dir, f"{item_id}{ext}")
|
||||
logger.info(f"Cover-Download: {url}")
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=20, follow_redirects=True) as client:
|
||||
r = await client.get(url)
|
||||
@@ -92,9 +93,12 @@ async def _download_cover(url: str, item_id: str) -> str | None:
|
||||
os.makedirs(settings.covers_dir, exist_ok=True)
|
||||
with open(dest, "wb") as f:
|
||||
f.write(r.content)
|
||||
logger.info(f"Cover gespeichert: {dest} ({len(r.content)} Bytes)")
|
||||
return dest
|
||||
else:
|
||||
logger.warning(f"Cover-Download HTTP {r.status_code}: {url}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Cover-Download fehlgeschlagen ({url}): {e}")
|
||||
logger.warning(f"Cover-Download Fehler ({url}): {e}")
|
||||
return None
|
||||
|
||||
|
||||
@@ -133,6 +137,8 @@ async def _apply_match(db: AsyncSession, item: LibraryItem, result: MatchResult,
|
||||
cover_path = await _download_cover(result.cover_url, item.id)
|
||||
if cover_path:
|
||||
item.cover_path = cover_path
|
||||
elif not result.cover_url:
|
||||
logger.info(f"Kein Cover-URL in Match-Ergebnis ({result.source}: {result.source_id})")
|
||||
|
||||
# Kapitel aus MusicBrainz-Tracklisting
|
||||
if result.chapters:
|
||||
|
||||
Reference in New Issue
Block a user