Skip to content

Commit e0c5e94

Browse files
alanzmeta-codesync[bot]
authored andcommitted
Add file watch logging for project switch decisions
Summary: We already have local logging of changes we receive related to file watching, both from VFS and the LSP client. To contextualise these, include logging of the decisions made at key points in the project loading lifecyle when ELP is running as an LSP server. Reviewed By: jcpetruzza Differential Revision: D86679575 fbshipit-source-id: dc4fb2bdab5b489757a618aefee33f544bce4767
1 parent b01a09f commit e0c5e94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/elp/src/server.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ impl Server {
507507
a_file_per_project = FxHashSet::default();
508508
}
509509
spinner.end();
510+
log::info!(target: FILE_WATCH_LOGGER_NAME, "Project reloading complete");
510511
self.reload_manager
511512
.lock()
512513
.set_reload_done(a_file_per_project);
@@ -558,6 +559,7 @@ impl Server {
558559

559560
let to_reload = self.reload_manager.lock().query_changed_files();
560561
if let Some(to_reload) = to_reload {
562+
log::info!(target: FILE_WATCH_LOGGER_NAME, "Asking for project reload");
561563
let query_config = self.reload_manager.lock().set_reload_active();
562564
self.reload_project(to_reload, query_config);
563565
}
@@ -1022,8 +1024,10 @@ impl Server {
10221024
log::info!(target: FILE_WATCH_LOGGER_NAME, "VFS change:{}:{}", &opened, &path);
10231025
}
10241026
if !opened {
1025-
// This call will add the file to the changed_files, picked
1026-
// up in `process_changes`, if it has changed.
1027+
// This call will add the file to the changed_files,
1028+
// picked up in `process_changes`, only if the new
1029+
// content is different from the current, checked via
1030+
// a hash.
10271031
vfs.set_file_contents(path, contents);
10281032
}
10291033
}
@@ -1396,9 +1400,11 @@ impl Server {
13961400
fn switch_workspaces(&mut self, spinner: &Spinner, new_projects: Vec<Project>) -> Result<()> {
13971401
if new_projects.is_empty() {
13981402
log::info!("nothing new, not switching workspaces");
1403+
log::info!(target: FILE_WATCH_LOGGER_NAME, "nothing new, not switching workspaces");
13991404
return Ok(());
14001405
}
14011406
log::info!("will switch workspaces");
1407+
log::info!(target: FILE_WATCH_LOGGER_NAME, "will switch workspaces");
14021408

14031409
let mut projects: Vec<Project> = self.projects.iter().cloned().collect();
14041410
for project in new_projects {
@@ -1878,6 +1884,7 @@ impl Server {
18781884
if !self.reload_manager.lock().ok_to_switch_workspace() {
18791885
// There are other changed files, abort this reload, to
18801886
// allow the next one.
1887+
log::info!(target: FILE_WATCH_LOGGER_NAME, "Not switching workspaces, more changed config files");
18811888
return Ok(false);
18821889
}
18831890
spinner.report("Switching to loaded projects".to_string());

0 commit comments

Comments
 (0)