init structure

This commit is contained in:
2025-08-26 09:35:24 +00:00
commit 42047598ae
18 changed files with 2023 additions and 0 deletions

63
src/logger_config.py Normal file
View File

@@ -0,0 +1,63 @@
"""
Simple logging configuration for the IQA framework.
Creates a log directory and stores log output files.
"""
import logging
from pathlib import Path
from datetime import datetime
def setup_logging(log_dir: str = "logs", log_level: str = "INFO") -> logging.Logger:
"""
Setup simple logging configuration with console and file output.
Args:
log_dir: Directory to store log files
log_level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
Returns:
Configured logger instance
"""
# Create log directory if it doesn't exist
log_path = Path(log_dir)
log_path.mkdir(parents=True, exist_ok=True)
# Generate log filename with timestamp
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
log_filename = f"iqa_benchmark_{timestamp}.log"
log_file_path = log_path / log_filename
# Setup basic logging configuration
logging.basicConfig(
level=getattr(logging, log_level.upper()),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
handlers=[
logging.StreamHandler(), # Console output
logging.FileHandler(log_file_path, encoding='utf-8') # File output
]
)
# Get logger and log setup info
logger = logging.getLogger(__name__)
logger.info(f"Logging initialized - Level: {log_level}")
logger.info(f"Log file: {log_file_path}")
logger.info(f"Log directory: {log_path.absolute()}")
return logger
def get_logger(name: str = None) -> logging.Logger:
"""
Get a logger instance with the specified name.
Args:
name: Logger name (usually __name__)
Returns:
Logger instance
"""
if name:
return logging.getLogger(name)
return logging.getLogger()