@@ -83,7 +83,7 @@ def init_file(filepath, pp_defs, pp_suffixes, include_dirs):
83
83
84
84
85
85
class LangServer :
86
- def __init__ (self , conn , debug_log = False , settings = {}):
86
+ def __init__ (self , conn , debug_log : bool = False , settings : dict = {}):
87
87
self .conn = conn
88
88
self .running = True
89
89
self .root_path = None
@@ -221,7 +221,9 @@ def serve_initialize(self, request):
221
221
)
222
222
self .source_dirs .add (self .root_path )
223
223
self .__config_logger (request )
224
- self .__load_config_file ()
224
+ init_debug_log = self .__load_config_file ()
225
+ if init_debug_log :
226
+ self .__config_logger (request )
225
227
self .__load_intrinsics ()
226
228
self .__add_source_dirs ()
227
229
@@ -1432,7 +1434,7 @@ def serve_default(self, request):
1432
1434
code = - 32601 , message = "method {} not found" .format (request ["method" ])
1433
1435
)
1434
1436
1435
- def __load_config_file (self ) -> None :
1437
+ def __load_config_file (self ) -> bool | None :
1436
1438
"""Loads the configuration file for the Language Server"""
1437
1439
1438
1440
# Check for config file
@@ -1459,7 +1461,13 @@ def __load_config_file(self) -> None:
1459
1461
self .__load_config_file_preproc (config_dict )
1460
1462
1461
1463
# Debug options
1462
- self .debug_log = config_dict .get ("debug_log" , self .debug_log )
1464
+ debugging : bool = config_dict .get ("debug_log" , self .debug_log )
1465
+ # If conf option is different than the debug option passed as a
1466
+ # command line argument return True so that debug log is setup
1467
+ if debugging != self .debug_log and not self .debug_log :
1468
+ self .debug_log = True
1469
+ return True
1470
+ return False
1463
1471
1464
1472
except FileNotFoundError :
1465
1473
msg = f"Error settings file '{ self .config } ' not found"
0 commit comments