Rename logger namespace from newmusic to soulsync
This commit is contained in:
parent
fe7ae29b8a
commit
67a5bcb5a7
3 changed files with 10 additions and 8 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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'}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue