Spaces:
Sleeping
Sleeping
Download gaia/utils/logging.py from tonthatthienvu/Final_Assignment: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/tonthatthienvu/Final_Assignment/resolve/main/gaia/utils/logging.py
- Command line
-
hf download hf://spaces/tonthatthienvu/Final_Assignment/gaia/utils/logging.py
-
curl -L -o logging.py https://huggingface.co/spaces/tonthatthienvu/Final_Assignment/resolve/main/gaia/utils/logging.py
1.09 kB
| #!/usr/bin/env python3 | |
| """ | |
| Logging utilities for GAIA system. | |
| """ | |
| import logging | |
| import sys | |
| from typing import Optional | |
| def setup_logging(level: str = "INFO", log_file: Optional[str] = None) -> logging.Logger: | |
| """Set up logging configuration for GAIA system.""" | |
| # Create logger | |
| logger = logging.getLogger("gaia") | |
| logger.setLevel(getattr(logging, level.upper())) | |
| # Clear existing handlers | |
| logger.handlers.clear() | |
| # Create formatter | |
| formatter = logging.Formatter( | |
| '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| ) | |
| # Console handler | |
| console_handler = logging.StreamHandler(sys.stdout) | |
| console_handler.setLevel(getattr(logging, level.upper())) | |
| console_handler.setFormatter(formatter) | |
| logger.addHandler(console_handler) | |
| # File handler if specified | |
| if log_file: | |
| file_handler = logging.FileHandler(log_file) | |
| file_handler.setLevel(getattr(logging, level.upper())) | |
| file_handler.setFormatter(formatter) | |
| logger.addHandler(file_handler) | |
| return logger |