Skip to content

Commit

Permalink
fix fortran-lang#348: more debug details
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonMiraj committed Mar 17, 2024
1 parent 3386073 commit e6514d4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def serve_initialize(self, request: dict):
)
self.source_dirs.add(self.root_path)

self._load_config_file()
config_dict = self._load_config_file()
self._resolve_globs_in_paths()
self._config_logger(request)
self._config_logger(request, config_dict)
self._load_intrinsics()
self._add_source_dirs()
if self._update_version_pypi():
Expand Down Expand Up @@ -1527,6 +1527,8 @@ def serve_default(self, request: dict):
def _load_config_file(self) -> None:
"""Loads the configuration file for the Language Server"""

config_dict = None

# Check for config files
default_conf_files = [self.config, ".fortlsrc", ".fortls.json", ".fortls"]
present_conf_files = [
Expand Down Expand Up @@ -1570,6 +1572,8 @@ def _load_config_file(self) -> None:
msg = f'Error: "{e}" while reading "{self.config}" Configuration file'
self.post_message(msg)

return config_dict

def _load_config_file_dirs(self, config_dict: dict) -> None:
self.excl_paths = set(config_dict.get("excl_paths", self.excl_paths))
self.source_dirs = set(config_dict.get("source_dirs", self.source_dirs))
Expand Down Expand Up @@ -1717,7 +1721,7 @@ def _get_source_files(self) -> list[str]:
file_list.append(p)
return file_list

def _config_logger(self, request) -> None:
def _config_logger(self, request, config_dict) -> None:
"""Configures the logger to save Language Server requests/responses to a file
the logger will by default output to the main (stderr, stdout) channels.
"""
Expand All @@ -1732,6 +1736,13 @@ def _config_logger(self, request) -> None:
consoleHandler = logging.StreamHandler()
log.addHandler(consoleHandler)
log.debug("REQUEST %s %s", request.get("id"), request.get("method"))
for arg in sys.argv[1:]:
log.debug("Cli Options: %s", arg)
if config_dict is not None:
for key, value in config_dict.items():
log.debug("Config Options: %s,%s", key, value)
else:
log.debug("No config file were passed")
self.post_messages.append([Severity.info, "fortls debugging enabled"])
else:
logging.basicConfig(format=fmt, datefmt="%H:%M:%S", level=logging.INFO)
Expand Down

0 comments on commit e6514d4

Please sign in to comment.