2023-11-17 10:20:26 +00:00
|
|
|
"""Warning: SIM_OUTPUT is a mutable global variable for the simulation output directory."""
|
2023-09-06 11:35:41 +01:00
|
|
|
from datetime import datetime
|
2024-04-18 16:38:42 +01:00
|
|
|
from enum import IntEnum
|
2023-11-17 10:20:26 +00:00
|
|
|
from pathlib import Path
|
2023-09-06 11:35:41 +01:00
|
|
|
|
2023-08-07 19:33:52 +01:00
|
|
|
from primaite import _PRIMAITE_ROOT
|
|
|
|
|
|
2023-11-17 10:20:26 +00:00
|
|
|
__all__ = ["SIM_OUTPUT"]
|
2023-09-06 11:35:41 +01:00
|
|
|
|
2023-11-17 10:20:26 +00:00
|
|
|
|
2024-04-18 16:38:42 +01:00
|
|
|
class LogLevel(IntEnum):
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Enum containing all the available log levels for PrimAITE simulation output."""
|
|
|
|
|
|
2024-04-18 16:38:42 +01:00
|
|
|
DEBUG = 10
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Debug items will be output to terminal or log file."""
|
2024-04-18 16:38:42 +01:00
|
|
|
INFO = 20
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Info items will be output to terminal or log file."""
|
2024-04-18 16:38:42 +01:00
|
|
|
WARNING = 30
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Warnings will be output to terminal or log file."""
|
2024-04-18 16:38:42 +01:00
|
|
|
ERROR = 40
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Errors will be output to terminal or log file."""
|
2024-04-18 16:38:42 +01:00
|
|
|
CRITICAL = 50
|
2024-04-17 18:13:00 +01:00
|
|
|
"""Critical errors will be output to terminal or log file."""
|
|
|
|
|
|
|
|
|
|
|
2024-01-05 11:25:57 +00:00
|
|
|
class _SimOutput:
|
2023-11-17 10:20:26 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
self._path: Path = (
|
|
|
|
|
_PRIMAITE_ROOT.parent.parent / "simulation_output" / datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
|
|
|
|
)
|
2024-02-15 15:45:18 +00:00
|
|
|
self.save_pcap_logs: bool = False
|
|
|
|
|
self.save_sys_logs: bool = False
|
2024-04-15 11:50:08 +01:00
|
|
|
self.write_sys_log_to_terminal: bool = False
|
2024-04-19 11:37:52 +01:00
|
|
|
self.sys_log_level: LogLevel = LogLevel.WARNING # default log level is at WARNING
|
2023-11-17 10:20:26 +00:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def path(self) -> Path:
|
|
|
|
|
return self._path
|
|
|
|
|
|
|
|
|
|
@path.setter
|
|
|
|
|
def path(self, new_path: Path) -> None:
|
|
|
|
|
self._path = new_path
|
|
|
|
|
self._path.mkdir(exist_ok=True, parents=True)
|
|
|
|
|
|
|
|
|
|
|
2024-01-05 11:25:57 +00:00
|
|
|
SIM_OUTPUT = _SimOutput()
|