First, it would be nice if it were possible to control the verbosity of the server traces. Currently, they are either on or off. But it would be nice to have an intermediate level, where the time/direction/method/id were logged, but the body/params/etc. were NOT.
Second, it would be nice to be able to control the trace level at runtime, so that traces could be turned on momentarily.
The LSP spec has outlined how to do both of these things.
It defines TraceLevel, an enum of 'off', 'messages' and 'verbose'. (I think our current traces map to 'off' and 'verbose', so I would like to add 'messages'.)
The initial level can be set in the InitializationParams as trace. During the lifetime of a server the TraceLevel can be changed with a $/setTrace notification. (Calva sends this notification when you change the trace level in the Calva settings window, though lsp4clj and clojure-lsp ignore it. I think the intention is to have a single setting that controls both the client and server trace level. I haven't noticed the notification from other editors, though they may send it too.)
I'm starting this Issue here in lsp4cl. It will need to generate traces that respect the trace level. And it will need some way of being told what the trace level should be. But clojure-lsp will have some responsibility too... I think it should handle the initialize and $/setTrace messages, and instruct lsp4clj what to do. I think it's better that the language servers handle these messages, because they may want to make their own decisions both about lsp4clj's trace level, but also about their own logging.
Ensure server is initialized with a trace-ch, to be prepared for level changes
Initialize server with a (stateful) trace level, defaulting to 'off'
Skip tracing if trace level is 'off`. Modify trace contents based on whether level is 'messages' or 'verbose'
Add lsp4clj.protocols.endpoint.IEndpoint/set-trace-level, and use it to modify trace level
(clojure-lsp) Call set-trace-level during initiailize
(clojure-lsp) Call set-trace-level upon $/setTrace
The new --trace option in clojure-lsp may still be useful, to control tracing before the initialize message.
Sounds great! I think I missed that from spec.
We could start supporting it on lsp4clj/clojure-lsp and change most used editors to support it, I can help with lsp-mode if needed
This is two related feature requests.
First, it would be nice if it were possible to control the verbosity of the server traces. Currently, they are either on or off. But it would be nice to have an intermediate level, where the time/direction/method/id were logged, but the body/params/etc. were NOT.
Second, it would be nice to be able to control the trace level at runtime, so that traces could be turned on momentarily.
The LSP spec has outlined how to do both of these things.
It defines TraceLevel, an enum of 'off', 'messages' and 'verbose'. (I think our current traces map to 'off' and 'verbose', so I would like to add 'messages'.)
The initial level can be set in the InitializationParams as
trace
. During the lifetime of a server the TraceLevel can be changed with a $/setTrace notification. (Calva sends this notification when you change the trace level in the Calva settings window, though lsp4clj and clojure-lsp ignore it. I think the intention is to have a single setting that controls both the client and server trace level. I haven't noticed the notification from other editors, though they may send it too.)I'm starting this Issue here in lsp4cl. It will need to generate traces that respect the trace level. And it will need some way of being told what the trace level should be. But clojure-lsp will have some responsibility too... I think it should handle the
initialize
and$/setTrace
messages, and instruct lsp4clj what to do. I think it's better that the language servers handle these messages, because they may want to make their own decisions both about lsp4clj's trace level, but also about their own logging.lsp4clj.protocols.endpoint.IEndpoint/set-trace-level
, and use it to modify trace levelset-trace-level
duringinitiailize
set-trace-level
upon$/setTrace
The new
--trace
option in clojure-lsp may still be useful, to control tracing before theinitialize
message.