>>> import logging
>>> import tempfile
>>> from pathlib import Path
>>> from spotforecast2_safe.manager.logger import setup_logging
>>>
>>> # Example 1: Basic console-only logging
>>> logger, log_path = setup_logging(level=logging.INFO)
>>> print(f"Logger name: {logger.name}")
Logger name: task_safe_n_to_1
>>> print(f"Log file path: {log_path}")
Log file path: None
>>>
>>> # Example 2: File and console logging for audit trail
>>> with tempfile.TemporaryDirectory() as tmpdir:
... log_dir = Path(tmpdir)
... logger, log_path = setup_logging(level=logging.DEBUG, log_dir=log_dir)
... logger.info("Model training started")
... logger.debug("Hyperparameter: learning_rate=0.01")
... print(f"Log file created: {log_path.exists()}")
... print(f"Log file suffix: {log_path.suffix}")
Log file created: True
Log file suffix: .log
>>>
>>> # Example 3: Verify log levels and file creation
>>> with tempfile.TemporaryDirectory() as tmpdir:
... logger, log_path = setup_logging(log_dir=Path(tmpdir))
... # Verify logger is configured
... assert logger.name == "task_safe_n_to_1"
... assert log_path is not None or len(logger.handlers) > 0
... print("Logger configured successfully")
Logger configured successfully
>>>
>>> # Example 4: Safety-critical scenario - file path verification
>>> with tempfile.TemporaryDirectory() as tmpdir:
... _, log_path = setup_logging(log_dir=Path(tmpdir))
... # In actual usage, log_path may be None if called multiple times
... # First call creates file, subsequent calls reuse handlers
... print("Logging system ready for audit trail")
Logging system ready for audit trail