From 535d50244d12df916b23065c67dbf1b714c301c7 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 14 Dec 2020 11:20:24 +0100 Subject: [PATCH 1/2] Don't create a log file by default. Fixes https://github.com/rescript-lang/rescript-vscode/issues/47. --- Changes.md | 1 + src/rescript-editor-support/Log.re | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Changes.md b/Changes.md index 36dfde53..cc4863b6 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,6 @@ ## master - Fix issue where type variables are printed with global renaming when hovering or autocompleting a module (see https://github.com/rescript-lang/rescript-editor-support/issues/38). +- Fix issue where a log file was always created (see https://github.com/rescript-lang/rescript-vscode/issues/47). ## Release 1.0.1 of rescript-vscode This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/232ad609766c415048750c5cc828973a9995f382) is vendored in [rescript-vscode 1.0.1](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.1). diff --git a/src/rescript-editor-support/Log.re b/src/rescript-editor-support/Log.re index 84b8d43f..b6f3af8a 100644 --- a/src/rescript-editor-support/Log.re +++ b/src/rescript-editor-support/Log.re @@ -1,28 +1,28 @@ let out = ref(None); let initial_dest = Filename.concat(Filename.get_temp_dir_name(), "lsp.log"); -out := Some(open_out(initial_dest)); -let setLocation = (location) => { - switch out^ { +let setLocation = location => { + switch (out^) { | None => () | Some(out) => close_out(out) }; output_string(stderr, "Setting log location: " ++ location ++ "\n"); flush(stderr); - out := Some(open_out(location)) + out := Some(open_out(location)); }; let spamError = ref(false); -let log = (msg) => - switch out^ { +let log = msg => { + if (spamError^) { + output_string(stderr, msg ++ "\n"); + flush(stderr); + }; + switch (out^) { | None => () | Some(out) => output_string(out, msg ++ "\n"); - if (spamError^) { - output_string(stderr, msg ++ "\n"); - flush(stderr) - }; - flush(out) - }; \ No newline at end of file + flush(out); + }; +}; From a442dcf0a07b348c605844dec76f321fe2cb939a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 14 Dec 2020 11:24:18 +0100 Subject: [PATCH 2/2] cleanup --- src/rescript-editor-support/Log.re | 2 -- src/rescript-editor-support/RescriptEditorSupport.re | 1 - 2 files changed, 3 deletions(-) diff --git a/src/rescript-editor-support/Log.re b/src/rescript-editor-support/Log.re index b6f3af8a..aaff0a4d 100644 --- a/src/rescript-editor-support/Log.re +++ b/src/rescript-editor-support/Log.re @@ -1,7 +1,5 @@ let out = ref(None); -let initial_dest = Filename.concat(Filename.get_temp_dir_name(), "lsp.log"); - let setLocation = location => { switch (out^) { | None => () diff --git a/src/rescript-editor-support/RescriptEditorSupport.re b/src/rescript-editor-support/RescriptEditorSupport.re index 09fa66ce..f89c7b75 100644 --- a/src/rescript-editor-support/RescriptEditorSupport.re +++ b/src/rescript-editor-support/RescriptEditorSupport.re @@ -41,7 +41,6 @@ let getInitialState = params => { Files.mkdirp(rootPath /+ "node_modules" /+ ".lsp"); Log.setLocation(rootPath /+ "node_modules" /+ ".lsp" /+ "debug.log"); Log.log("Hello - from " ++ Sys.executable_name); - Log.log("Previous log location: " ++ Log.initial_dest); Rpc.sendNotification( stdout,