Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit b400cdb

Browse files
committed
Add json spec
1 parent eabf89e commit b400cdb

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

README.md

+39-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Try it at https://microsoft.github.io/language-server-protocol/inspector/.
1212

1313
## Motivation
1414

15-
When you are using [vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) to develop a language server, it's possible to specify a setting `"[langId]".trace.server: "verbose"` to make the Language Client log the LSP communication. This log is useful for developing and testing the Language Server, but the log can be lengthy — 5 seconds of usage might generate 5000 lines LSP log. This makes it hard to gain insight from the logs.
15+
When you are using [vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) to develop a language server, it's possible to specify a setting `"[langId].trace.server": "verbose"` to make the Language Client log the LSP communication. This log is useful for developing and testing the Language Server, but the log can be lengthy — using the editor for 5 seconds could generate 5000 lines of LSP log. This makes it hard to gain insight from the logs.
1616

17-
This inspector visualizes the logs to make it easy to understand the communication between the Language Client / Server. It also lets you filter down the logs by search query or language features, so you can quickly identify the logs you are interested in.
17+
This inspector visualizes the logs to make it easy to understand the communication between the Language Client / Server. It also lets you filter the logs by search query or language features, so you can quickly identify the logs you are interested in.
1818

1919
![lsp-inspector](https://user-images.githubusercontent.com/4033249/41323525-ba73697a-6e63-11e8-92a3-c655b34126f6.gif)
2020

@@ -31,6 +31,43 @@ This inspector visualizes the logs to make it easy to understand the communicati
3131
- Load it from the web app.
3232
- You can try it on real-world logs file at `/tests/unit/logParser/fixture`.
3333

34+
## Log Format
35+
36+
The Inspector takes two log formats: `Text` and `JSON`.
37+
38+
- `Text`:
39+
- Logs generated by setting `"[langId].trace.server": "verbose"`.
40+
- Logs generated by setting `"[langId].trace.server": { "format": "Text" }`
41+
- `JSON`: Logs generated by setting: `"[langId].trace.server": { "format": "JSON" }`
42+
43+
The Inspector could load any JSON logs, as long as they follow this format:
44+
45+
```ts
46+
export type MsgKind =
47+
| 'send-notification'
48+
| 'recv-notification'
49+
| 'send-request'
50+
| 'recv-request'
51+
| 'send-response'
52+
| 'recv-response'
53+
54+
export interface LspItem {
55+
type: MsgKind
56+
message: any
57+
timestamp: unix timestamp
58+
}
59+
60+
```
61+
62+
Each line is terminated with `\r\n`.
63+
64+
Here is a sample:
65+
66+
```
67+
{"type":"receive-response","message":{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":true}}}},"timestamp":1534721620392}\r\n
68+
{"type":"send-notification","message":{"jsonrpc":"2.0","method":"initialized","params":{}},"timestamp":1534721620393}\r\n
69+
```
70+
3471
## Running & Developing
3572

3673
- `yarn`

0 commit comments

Comments
 (0)