"Trace server messages" setting doesn't show LSP JSON-RPC messages in the logs
Your environment
Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:
haskell-language-server version: 1.1.0.1 (GHC: 8.8.4) (PATH: /home/jhrcek/.local/bin/haskell-language-server) (GIT hash: 0cc89d209791c4bc200bf582f0e5f2a8b2465220)
Tool versions found on the $PATH
cabal: 3.4.0.0
stack: 2.7.1
ghc: 8.8.4
Which OS do you use:
- Fedora 34
Which lsp-client do you use:
- vscode
Steps to reproduce
In vscode haskell extension setting set "Haskell > Trace: server" to "messages" (and then restart vscode to be sure extension setting was applied)
Expected behaviour
When I go to View > Output and select "Haskell" I'm expecting to see JSON-RPC messages being exchanged between vscode-haskell extension and haskell-language-server. I'm pretty sure I saw messages like these when I used to use hie (haskell-ide-engine) but in HLS this setting doesn't seem to have any effect.
Actual behaviour
I "only" see debug messages, but no JSON-RPC messages.
Hi, thanks for asking the question. To enable messages you can set the env var LSP_TEST_LOG_MESSAGES=true (see an example in the github test workflow, where other related env vars are used)
I guess the amount of log with messages enabled is overwhelming so it is better to not show them by default. Maybe another mechanism could be used though (TRACE log level? an option to pass to hls executable?)
Definitely it should be documented somewhere and be easily discoverable.
EDIT: The use of the en var is documented in the lsp package: https://github.com/haskell/lsp/blob/master/README.md but i think it is worth to add them here, in the troubleshooting section: https://github.com/haskell/haskell-language-server#troubleshooting-the-server prs welcome, as usual 😃
Thanks for the details. I'll gladly document this once I managed to turn on the message tracing. So far I tried couple of ways, e.g. I added these to my .bashrc
export LSP_TEST_LOG_MESSAGES=true
export LSP_TEST_LOG_STDERR=true
after sourcing it I started vscode and double checked that those env vars are indeed set for the haskell-language-server process:
$ strings /proc/$(pidof haskell-language-server-8.8.4)/environ | grep LSP --color
LSP_TEST_LOG_STDERR=true
LSP_TEST_LOG_MESSAGES=true
But I still couldn't see any json-rpc messages logged. I'll dig deeper into source code later and hopefully find a way to enable the message tracing, but in the meantime It would be helpful if you could check if you can enable those messages on your side :pray:
Is it possible that HLS is starting session in some way that ignores those env vars?
Mmm maybe i overlooked it and only are taken in account when the session is started using lsp-test (ultimately the env var names have TEST) In that case we should port or move the behaviour to lsp itself (or in hls if lsp itself is not suitable)
EDIT: I think that is the case, sorry for the confusion:
https://github.com/haskell/lsp/blob/907a69791cca89391b3831b6a113882b9d99463a/lsp-test/src/Language/LSP/Test.hs#L264-L272
Seconded, this was very useful and it would be good to have it back! (Fortunately you can still get this from the client with the Emacs client)
I think this ultimately means that -d no longer emits these.
Not sure if this is outdated but I think it's still somewhat useful to get the messages.
This is no longer an issue. Setting "Haskell > Trace: Server" to "verbose" in vscode shows the client-server messages in the output window.