import logging import os from datetime import datetime def setup_logger(log_level=logging.INFO): """Configure and return a logger instance for the application.""" # Create logs directory if it doesn't exist log_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'logs') os.makedirs(log_dir, exist_ok=True) # Create unique log filename with timestamp timestamp = datetime.now().strftime('%Y%m%d_%H%M%S') log_file = os.path.join(log_dir, f'cv_parser_{timestamp}.log') # Configure logging logging.basicConfig( level=log_level, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler(log_file), logging.StreamHandler() # Also log to console ] ) return logging.getLogger('cv_parser') # Create a default logger instance logger = setup_logger()