ruff
ruff copied to clipboard
Replace `tracing` log functions in `ruff server` with LSP-compliant logging functions
Summary
Closes https://github.com/astral-sh/ruff/issues/10968.
At the moment, the log level is always set to Info
. Log level configuration will be implemented in a follow-up.
Test Plan
Add a series of logs, one for each level, to the definition of Server::new
, after the logger is initialized:
You should see the following logs in the output of the VS Code extension:
ruff-ecosystem
results
Linter (stable)
✅ ecosystem check detected no linter changes.
Linter (preview)
✅ ecosystem check detected no linter changes.
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
Is there an alternate design whereby we wire up tracing
to emit to the LSP client? I.e., some kind of tracing
configuration that would let us continue to use tracing::info!
and friends, but also emit to the client?
@charliermarsh I think that should be possible by setting up our own subscriber that then forwards messages to the LSP.
I think the problem this approach is that it only works for ruff_server, but we will use tracing in runes too and we don't have the luxury to change all tracing calls there.
I think we need to explore an alternative approach that captures all tracing messages (subscriber) and forwards them correctly OR setup an alternative subscriber that writes e.g. to a file, although I would prefer seeing the tracing messages in vs code.
Yeah I would prefer trying to integrate this into tracing too (for those reasons, plus it's the API I would've naturally reached for if I went to write code in the LSP as a future editor / author). @snowsignal can you give it a shot?
@charliermarsh Sure, I'll see what I can do!
This PR is really outdated, especially with the major refactors we made to server initialization. I'll re-implement this feature in a new PR that's based off of the latest main
.