Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace level should be configurable #27

Closed
Tracked by #1310
mainej opened this issue Sep 29, 2022 · 1 comment · Fixed by #28
Closed
Tracked by #1310

Trace level should be configurable #27

mainej opened this issue Sep 29, 2022 · 1 comment · Fixed by #28

Comments

@mainej
Copy link
Contributor

mainej commented Sep 29, 2022

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.

  1. Ensure server is initialized with a trace-ch, to be prepared for level changes
  2. Initialize server with a (stateful) trace level, defaulting to 'off'
  3. Skip tracing if trace level is 'off`. Modify trace contents based on whether level is 'messages' or 'verbose'
  4. Add lsp4clj.protocols.endpoint.IEndpoint/set-trace-level, and use it to modify trace level
  5. (clojure-lsp) Call set-trace-level during initiailize
  6. (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.

@ericdallo
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants