refactor: unify logging to standard logging.getLogger(__name__) pattern

Replace custom get_logger() wrapper with standard Python logging pattern
across executor.py and quarantine.py. Remove dead logger imports from
reports.py. Remove get_logger() function from logging_config.py and its
tests. Reduces logging patterns from 2 to 1.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
windyboy
2026-09-27 10:53:56 +08:00
co-authored by Claude Sonnet 4.5
parent fe03a31dd4
commit 8832f5da3f
5 changed files with 4 additions and 45 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ from typing import Optional
from uuid import uuid4
from vlm.config import Config
from vlm.logging_config import get_logger, log_operation
from vlm.logging_config import log_operation
from vlm.models import ExecutionPlan, FileOperation, OperationResult, RollbackLog
from vlm.quarantine import QuarantineManager
from vlm.state import StateManager
@@ -41,7 +41,7 @@ class ExecutionEngine:
verbose_operations: Emit per-operation dry-run logs at INFO when True
state_manager: Optional state manager for updating file statuses
"""
self.logger = logger or get_logger()
self.logger = logger or logging.getLogger(__name__)
self.config = config
self.verbose_operations = verbose_operations
self.state_manager = state_manager
-15
View File
@@ -106,21 +106,6 @@ def setup_logging(
return logger
def get_logger() -> logging.Logger:
"""Get the configured VLM logger instance.
Returns:
Logger instance (creates default configuration if not already set up)
"""
logger = logging.getLogger("vlm")
# If logger has no handlers, set up default configuration
if not logger.handlers:
setup_logging()
return logger
def log_operation(
logger: logging.Logger,
level: int,
+2 -2
View File
@@ -16,7 +16,7 @@ from pathlib import Path
from typing import Optional
from .config import Config
from .logging_config import get_logger, log_operation
from .logging_config import log_operation
from .models import FileOperation, OperationResult, QuarantineEntry, QuarantineManifest
from .scanner import categorize_file
from .utils import utc_now
@@ -33,7 +33,7 @@ class QuarantineManager:
logger: Optional logger instance (uses default if not provided)
"""
self.config = config
self.logger = logger or get_logger()
self.logger = logger or logging.getLogger(__name__)
def quarantine_file(
self,
-3
View File
@@ -9,15 +9,12 @@ This module provides functionality to generate various reports about the video l
import csv
import json
import logging
from datetime import datetime, timezone
from io import StringIO
from pathlib import Path
from vlm.models import DuplicateGroup, MovieIdentity, SeasonCompleteness, SeriesIdentity, VideoFile
logger = logging.getLogger(__name__)
def _normalize_to_utc(timestamp: datetime) -> datetime:
"""Normalize a datetime to a UTC instant."""
-23
View File
@@ -8,7 +8,6 @@ import pytest
from vlm.logging_config import (
MAX_LOG_SIZE,
default_log_dir,
get_logger,
log_operation,
setup_logging,
)
@@ -239,28 +238,6 @@ class TestLogRotation:
assert log_file.stat().st_size < MAX_LOG_SIZE
class TestGetLogger:
"""Test get_logger function."""
def test_get_logger_returns_logger(self):
"""Test that get_logger returns a logger instance."""
logger = get_logger()
assert logger is not None
assert logger.name == "vlm"
def test_get_logger_creates_default_config(self):
"""Test that get_logger creates default configuration if needed."""
# Clear any existing handlers
logger = logging.getLogger("vlm")
logger.handlers.clear()
# Get logger should set up default configuration
logger = get_logger()
assert len(logger.handlers) > 0
class TestLogOperation:
"""Test log_operation helper function."""