ebkalderon / tower-lsp

Language Server Protocol implementation written in Rust
Apache License 2.0
952 stars 54 forks source link

Question: `tracing_subscriber::fmt()` in examples #423

Open Schottkyc137 opened 1 week ago

Schottkyc137 commented 1 week ago

In One of the example files where the language server communicates with a client using stdin and stdout, the logging framework is initialised using tracing_subscriber::fmt().init(). Is this best practice? Doesn't this mean that the language server interferes with the logging framework? One of my projects produces a warning since a client sends a message that is not implemented and consequently causing the server to malfunction. The following is an excerpt from the error log:

[coc.nvim] Connection to server dts is erroring, Header must provide a Content-Length property.
{"\u001b[2m2024-06-30t17":"26:58.978499Z\u001b[0m \u001b[33m WARN\u001b[0m \u001b[2mtower_lsp\u001b[0m\u001b[2m:\u001b[0m Got a workspace/didChangeConfiguration notification, but it is not implemented\nContent-Leng
[coc.nvim] Connection to server dts is erroring, Header must provide a Content-Length property.
{"{\"jsonrpc\"":"\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"diagnostics\":[{\"code\":\"expected\",\"message\":\"Expected one of /dts-v1/, /memreserve/, /include/, /delete-node/, /omit-if-n
o-ref/, '/', reference\",\"range\":{\"end\":{\"character\":1,\"line\":0},\"start\":{\"character\":0,\"line\":0}},\"severity\":1,\"source\":\"ginko_ls\"}],\"uri\":\"file:///Users/lukasscheller/.local/share/nvim/site
/pack/x.dts\"}}\u001b[2m2024-06-30T17:26:58.984067Z\u001b[0m \u001b[32m INFO\u001b[0m \u001b[2mtower_lsp::service::layers\u001b[0m\u001b[2m:\u001b[0m shutdown request received, shutting down\nContent-Length: 38"}. 
Shutting down server.

Is there a reason why the tracing_subscriber::fmt().init() method is used (since it can interfere with the actual messages)? Is there a better methods? Thanks for all replies!