Logging Module
The log_config module provides centralized logging configuration for the entire hiten package.
This module provides centralized logging configuration for the entire hiten package, including console and file output with timestamped log files. Logging is automatically configured when this module is imported.
Logging Configuration
Functions for setting up logging configuration.
- hiten.utils.log_config.setup_logging(level=20, format_string='%(asctime)s - %(name)s - %(levelname)s - %(message)s', save_to_file=True, log_dir='results/logs')[source]
Configure logging to stdout and optionally to a file.
This function sets up the root logger with both console and file handlers. It clears any existing handlers to avoid duplicates and creates timestamped log files when file logging is enabled.
- Parameters:
level (int, default logging.INFO) – Logging level (e.g., logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR).
format_string (str, default '%(asctime)s - %(name)s - %(levelname)s - %(message)s') – Format string for log messages using standard logging format codes.
save_to_file (bool, default True) – Whether to save logs to a file in addition to console output.
log_dir (str, default 'results/logs') – Directory path where log files will be saved. Will be created if it doesn’t exist.
- Return type:
None
Notes
The function automatically creates the log directory if it doesn’t exist. Log files are named with timestamps in the format ‘run_YYYYMMDD_HHMMSS.txt’.