|
28 | 28 | class HecDss: |
29 | 29 | """ Main class for working with DSS files |
30 | 30 | """ |
31 | | - def __init__(self, filename:str, enable_dll_logging:bool = False): |
| 31 | + def __init__(self, filename:str, enable_dll_logging:bool = False, message_level:int = 0): |
32 | 32 | """constructor for HecDSS |
33 | 33 |
|
34 | 34 | Args: |
35 | 35 | filename (str): DSS filename to be opened; it will be created if it doesn't exist. |
36 | 36 | enable_dll_logging (bool): If True, capture DLL messages to Python logging. Default False. |
| 37 | + message_level (int): DLL message level (0-15). Default 0 (silent). |
37 | 38 | """ |
38 | 39 |
|
39 | 40 | self._native = _Native() |
40 | 41 | self._dll_monitor = None |
41 | 42 |
|
| 43 | + # Set DLL message level (0 = silent by default) |
| 44 | + self._native.hec_dss_set_debug_level(message_level) |
| 45 | + |
42 | 46 | # Setup DLL logging if requested |
43 | 47 | if enable_dll_logging: |
44 | 48 | self._setup_dll_logging() |
@@ -75,14 +79,17 @@ def _setup_dll_logging(self): |
75 | 79 | # Create temp log file |
76 | 80 | log_file_path = self._dll_monitor.setup_temp_log_file() |
77 | 81 |
|
78 | | - # Tell DLL to use this log file |
| 82 | + # Tell DLL to use this log file (requires zopenLog function in DLL) |
79 | 83 | status = self._native.hec_dss_open_log_file(log_file_path) |
| 84 | + |
80 | 85 | if status == 0: |
81 | | - # Start monitoring |
| 86 | + # zopenLog worked, monitor the file |
82 | 87 | self._dll_monitor.start_monitoring() |
83 | 88 | logger.debug("DLL logging enabled, monitoring: %s", log_file_path) |
84 | 89 | else: |
85 | | - logger.warning("Could not enable DLL log file, messages will not be captured") |
| 90 | + # zopenLog not available, can't capture DLL output to file |
| 91 | + logger.warning("zopenLog not available in DLL, cannot capture DLL output to file") |
| 92 | + self._dll_monitor.stop_monitoring() |
86 | 93 | self._dll_monitor = None |
87 | 94 | @staticmethod |
88 | 95 | def set_global_debug_level(level: int) -> None: |
|
0 commit comments