From 01d118daa6f2fe0b274a5e2cf6be0d86ac45b822 Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Tue, 21 Apr 2026 15:48:47 +0300 Subject: [PATCH] Separate AcoustID file logging - keep AcoustID logs out of app.log - route client and verification to logs/acoustid.log - align tag writer with the soulsync logger namespace --- core/acoustid_client.py | 30 ++++++++++++++++-------------- core/acoustid_verification.py | 2 +- core/tag_writer.py | 2 +- web_server.py | 4 ++-- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/core/acoustid_client.py b/core/acoustid_client.py index 2e92a609..a0edb64b 100644 --- a/core/acoustid_client.py +++ b/core/acoustid_client.py @@ -20,6 +20,7 @@ from typing import Dict, List, Optional, Any, Tuple from pathlib import Path import os import shutil +import logging import logging.handlers from utils.logging_config import get_logger @@ -29,22 +30,23 @@ from config.settings import config_manager FPCALC_BIN_DIR = Path(__file__).parent.parent / "bin" CHROMAPRINT_VERSION = "1.5.1" -# Set up dedicated AcoustID logger with its own file -logger = get_logger("acoustid_client") - -# Add dedicated file handler for AcoustID logs alongside the configured app log +_acoustid_logger = logging.getLogger("soulsync.acoustid") +_acoustid_logger.setLevel(logging.DEBUG) _acoustid_log_path = Path(config_manager.get('logging.path', 'logs/app.log')).parent / "acoustid.log" _acoustid_log_path.parent.mkdir(parents=True, exist_ok=True) -_acoustid_file_handler = logging.handlers.RotatingFileHandler( - _acoustid_log_path, encoding='utf-8', maxBytes=5*1024*1024, backupCount=2 -) -_acoustid_file_handler.setLevel(logging.DEBUG) -_acoustid_file_handler.setFormatter(logging.Formatter( - fmt='%(asctime)s - %(name)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s', - datefmt='%Y-%m-%d %H:%M:%S' -)) -logger.addHandler(_acoustid_file_handler) -logging.getLogger("soulsync.acoustid_verification").addHandler(_acoustid_file_handler) +if not _acoustid_logger.handlers: + _acoustid_file_handler = logging.handlers.RotatingFileHandler( + _acoustid_log_path, encoding='utf-8', maxBytes=5*1024*1024, backupCount=2 + ) + _acoustid_file_handler.setLevel(logging.DEBUG) + _acoustid_file_handler.setFormatter(logging.Formatter( + fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + )) + _acoustid_logger.addHandler(_acoustid_file_handler) + _acoustid_logger.propagate = False + +logger = get_logger("acoustid.client") # Check if pyacoustid is available try: diff --git a/core/acoustid_verification.py b/core/acoustid_verification.py index 5bfb6f92..ee4100b5 100644 --- a/core/acoustid_verification.py +++ b/core/acoustid_verification.py @@ -17,7 +17,7 @@ from utils.logging_config import get_logger from core.acoustid_client import AcoustIDClient from core.musicbrainz_client import MusicBrainzClient -logger = get_logger("acoustid_verification") +logger = get_logger("acoustid.verification") # Thresholds MIN_ACOUSTID_SCORE = 0.80 # Minimum AcoustID fingerprint score to trust diff --git a/core/tag_writer.py b/core/tag_writer.py index d1d11c21..cbdfdf11 100644 --- a/core/tag_writer.py +++ b/core/tag_writer.py @@ -16,7 +16,7 @@ from mutagen.mp4 import MP4, MP4Cover, MP4FreeForm from mutagen.oggvorbis import OggVorbis from mutagen.apev2 import APEv2, APENoHeaderError -logger = logging.getLogger("soulsync.tag_writer") +logger = logging.getLogger("tag_writer") # Supported extensions SUPPORTED_EXTENSIONS = {'.mp3', '.flac', '.ogg', '.oga', '.opus', '.m4a', '.mp4'} diff --git a/web_server.py b/web_server.py index f52df3f7..1ad2ec30 100644 --- a/web_server.py +++ b/web_server.py @@ -6396,8 +6396,8 @@ def get_log_tail(): log_map = { 'app': Path(_log_path), - 'post_processing': _log_dir / 'post_processing.log', 'acoustid': _log_dir / 'acoustid.log', + 'post_processing': _log_dir / 'post_processing.log', 'source_reuse': _log_dir / 'source_reuse.log', } log_path = log_map.get(log_source, log_map['app']) @@ -54425,8 +54425,8 @@ def _emit_live_log_loop(): _active_source = 'app' log_map = { 'app': Path(_log_path), - 'post_processing': _log_dir / 'post_processing.log', 'acoustid': _log_dir / 'acoustid.log', + 'post_processing': _log_dir / 'post_processing.log', 'source_reuse': _log_dir / 'source_reuse.log', } while not globals().get('IS_SHUTTING_DOWN', False):