-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_config.py
More file actions
67 lines (59 loc) · 2.1 KB
/
debug_config.py
File metadata and controls
67 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Configuration-based debug system for MagGeo.
"""
import yaml
from dataclasses import dataclass
from typing import Optional
from pathlib import Path
@dataclass
class DebugConfig:
"""Debug configuration settings."""
enabled: bool = False
log_level: str = "INFO" # DEBUG, INFO, WARNING, ERROR
save_temp_files: bool = False
temp_dir: str = "temp_data"
log_file: str = "maggeo.log"
# Specific debug options
log_parameters: bool = True
log_gps_data: bool = True
log_swarm_data: bool = True
log_interpolation: bool = True
log_chaos_values: bool = True
# File saving options
save_gps_data: bool = True
save_swarm_data: bool = True
save_interpolation: bool = True
save_chaos_results: bool = True
def load_debug_config(config_path: Optional[str] = None) -> DebugConfig:
"""Load debug configuration from YAML file or use defaults."""
if config_path and Path(config_path).exists():
with open(config_path, 'r') as f:
config_dict = yaml.safe_load(f).get('debug', {})
return DebugConfig(**config_dict)
return DebugConfig()
def create_debug_config_template(output_path: str = "debug_config.yml"):
"""Create a template debug configuration file."""
template = {
'debug': {
'enabled': False,
'log_level': 'INFO',
'save_temp_files': False,
'temp_dir': 'temp_data',
'log_file': 'maggeo.log',
'log_parameters': True,
'log_gps_data': True,
'log_swarm_data': True,
'log_interpolation': True,
'log_chaos_values': True,
'save_gps_data': True,
'save_swarm_data': True,
'save_interpolation': True,
'save_chaos_results': True
}
}
with open(output_path, 'w') as f:
yaml.dump(template, f, default_flow_style=False, indent=2)
print(f"Debug configuration template created at: {output_path}")
print("Edit this file and set 'enabled: true' to activate debug mode.")
if __name__ == "__main__":
create_debug_config_template()