Rename logger namespace from newmusic to soulsync

This commit is contained in:
Antti Kettunen 2026-04-20 09:23:27 +03:00
parent fe7ae29b8a
commit 67a5bcb5a7
No known key found for this signature in database
GPG key ID: C6B2A3D250359BD7
3 changed files with 10 additions and 8 deletions

View file

@ -44,7 +44,7 @@ _acoustid_file_handler.setFormatter(logging.Formatter(
datefmt='%Y-%m-%d %H:%M:%S'
))
logger.addHandler(_acoustid_file_handler)
logging.getLogger("newmusic.acoustid_verification").addHandler(_acoustid_file_handler)
logging.getLogger("soulsync.acoustid_verification").addHandler(_acoustid_file_handler)
# Check if pyacoustid is available
try:

View file

@ -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("newmusic.tag_writer")
logger = logging.getLogger("soulsync.tag_writer")
# Supported extensions
SUPPORTED_EXTENSIONS = {'.mp3', '.flac', '.ogg', '.oga', '.opus', '.m4a', '.mp4'}

View file

@ -6,6 +6,8 @@ from pathlib import Path
from datetime import datetime
from typing import Optional
LOGGER_NAMESPACE = "soulsync"
class SafeFormatter(logging.Formatter):
"""Formatter that handles Unicode characters safely on Windows"""
@ -52,7 +54,7 @@ class ColoredFormatter(SafeFormatter):
def setup_logging(level: str = "INFO", log_file: Optional[str] = None) -> logging.Logger:
log_level = getattr(logging, level.upper(), logging.INFO)
logger = logging.getLogger("newmusic")
logger = logging.getLogger(LOGGER_NAMESPACE)
logger.setLevel(log_level)
if logger.handlers:
@ -91,15 +93,15 @@ def setup_logging(level: str = "INFO", log_file: Optional[str] = None) -> loggin
return logger
def get_logger(name: str) -> logging.Logger:
return logging.getLogger(f"newmusic.{name}")
return logging.getLogger(f"{LOGGER_NAMESPACE}.{name}")
def set_log_level(level: str) -> bool:
"""Dynamically change the log level for all loggers without restart"""
try:
log_level = getattr(logging, level.upper(), logging.INFO)
# Get the root "newmusic" logger
root_logger = logging.getLogger("newmusic")
# Get the root "soulsync" logger
root_logger = logging.getLogger(LOGGER_NAMESPACE)
root_logger.setLevel(log_level)
# Update all handlers
@ -109,12 +111,12 @@ def set_log_level(level: str) -> bool:
root_logger.info(f"Log level changed to: {level.upper()}")
return True
except Exception as e:
logging.getLogger("newmusic").error(f"Error setting log level: {e}")
logging.getLogger(LOGGER_NAMESPACE).error(f"Error setting log level: {e}")
return False
def get_current_log_level() -> str:
"""Get the current log level"""
root_logger = logging.getLogger("newmusic")
root_logger = logging.getLogger(LOGGER_NAMESPACE)
return logging.getLevelName(root_logger.level)
main_logger = get_logger("main")