Skip to content

Commit caf0385

Browse files
adamchesterKrzysztof-Cieslak
authored andcommitted
Added FSAC request log (default off) (#109)
1 parent e782971 commit caf0385

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

release/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@
158158
"type": "object",
159159
"title": "FSharp configuration",
160160
"properties": {
161+
"FSharp.logLanguageServiceRequestsToConsole": {
162+
"type": "boolean",
163+
"default": false,
164+
"description": "Log language service (FSAC) requests to the developer tools console"
165+
},
161166
"FSharp.automaticProjectModification": {
162167
"type": "boolean",
163168
"default": false,

src/Core/LanguageService.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ open Ionide.VSCode.Helpers
1313
module LanguageService =
1414
let ax = Node.require.Invoke "axios" |> unbox<Axios.AxiosStatic>
1515

16+
let logRequests =
17+
workspace.getConfiguration().get("FSharp.logLanguageServiceRequestsToConsole", false)
18+
1619
let genPort () =
1720
let r = JS.Math.random ()
1821
let r' = r * (8999. - 8100.) + 8100.
@@ -24,10 +27,15 @@ module LanguageService =
2427
let mutable private service : child_process_types.ChildProcess option = None
2528

2629
let request<'a, 'b> ep id (obj : 'a) =
30+
if logRequests then Browser.console.log ("[IONIDE-FSAC-REQ]", id, ep, obj)
2731
ax.post (ep, obj)
2832
|> Promise.success(fun r ->
2933
try
3034
let res = (r.data |> unbox<string[]>).[id] |> JS.JSON.parse |> unbox<'b>
35+
if logRequests then
36+
match res?Kind |> unbox with
37+
| "error" -> Browser.console.error ("[IONIDE-FSAC-RES]", id, ep, res?Kind, res?Data)
38+
| _ -> Browser.console.info ("[IONIDE-FSAC-RES]", id, ep, res?Kind, res?Data)
3139
if res?Kind |> unbox = "error" || res?Kind |> unbox = "info" then null |> unbox
3240
else res
3341
with

0 commit comments

Comments
 (0)