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' datefmt='%Y-%m-%d %H:%M:%S'
)) ))
logger.addHandler(_acoustid_file_handler) 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 # Check if pyacoustid is available
try: try:

View file

@ -16,7 +16,7 @@ from mutagen.mp4 import MP4, MP4Cover, MP4FreeForm
from mutagen.oggvorbis import OggVorbis from mutagen.oggvorbis import OggVorbis
from mutagen.apev2 import APEv2, APENoHeaderError from mutagen.apev2 import APEv2, APENoHeaderError
logger = logging.getLogger("newmusic.tag_writer") logger = logging.getLogger("soulsync.tag_writer")
# Supported extensions # Supported extensions
SUPPORTED_EXTENSIONS = {'.mp3', '.flac', '.ogg', '.oga', '.opus', '.m4a', '.mp4'} SUPPORTED_EXTENSIONS = {'.mp3', '.flac', '.ogg', '.oga', '.opus', '.m4a', '.mp4'}

View file

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