Download logger.py from vietlethe/CV_parser: direct link, hf CLI and curl.
- Browser
- Download file 905 Bytes
-
https://huggingface.co/spaces/vietlethe/CV_parser/resolve/main/logger.py
- Command line
-
hf download hf://spaces/vietlethe/CV_parser/logger.py
-
curl -L -o logger.py https://huggingface.co/spaces/vietlethe/CV_parser/resolve/main/logger.py
905 Bytes
| 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() |