Skip to content

Just like request and response, events are also logged as formatted json for readability #54105

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

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export function formatMessage<T extends protocol.Message>(msg: T, logger: Logger

const json = JSON.stringify(msg);
if (verboseLogging) {
logger.info(`${msg.type}:${indent(json)}`);
logger.info(`${msg.type}:${indent(JSON.stringify(msg, undefined, " "))}`);
}

const len = byteLength(json, "utf8");
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/helpers/tsserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export function createLoggerWritingToConsole(host: TestServerHost): Logger {

function sanitizeLog(s: string) {
return s.replace(/Elapsed::?\s*\d+(?:\.\d+)?ms/g, "Elapsed:: *ms")
.replace(/\"updateGraphDurationMs\"\:\d+(?:\.\d+)?/g, `"updateGraphDurationMs":*`)
.replace(/\"createAutoImportProviderProgramDurationMs\"\:\d+(?:\.\d+)?/g, `"createAutoImportProviderProgramDurationMs":*`)
.replace(/\"updateGraphDurationMs\"\:\s*\d+(?:\.\d+)?/g, `"updateGraphDurationMs": *`)
.replace(/\"createAutoImportProviderProgramDurationMs\"\:\s*\d+(?:\.\d+)?/g, `"createAutoImportProviderProgramDurationMs": *`)
.replace(`"version":"${ts.version}"`, `"version":"FakeVersion"`)
.replace(/getCompletionData: Get current token: \d+(?:\.\d+)?/g, `getCompletionData: Get current token: *`)
.replace(/getCompletionData: Is inside comment: \d+(?:\.\d+)?/g, `getCompletionData: Is inside comment: *`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ Before running Timeout callback:: count: 1
1: checkOne

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":2}}
{
"seq": 0,
"type": "event",
"event": "requestCompleted",
"body": {
"request_seq": 2
}
}
TestServerCancellationToken:: resetRequest:: 2 is as expected
After running Timeout callback:: count: 0

Expand Down Expand Up @@ -148,7 +155,14 @@ Before running Timeout callback:: count: 1

TestServerCancellationToken:: Cancellation is requested
Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":3}}
{
"seq": 0,
"type": "event",
"event": "requestCompleted",
"body": {
"request_seq": 3
}
}
TestServerCancellationToken:: resetRequest:: 3 is as expected
After running Timeout callback:: count: 0

Expand Down Expand Up @@ -177,7 +191,15 @@ Before running Timeout callback:: count: 1
3: checkOne

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/a/app.ts","diagnostics":[]}}
{
"seq": 0,
"type": "event",
"event": "syntaxDiag",
"body": {
"file": "/a/app.ts",
"diagnostics": []
}
}
TestServerCancellationToken:: resetRequest:: 5 is as expected
After running Timeout callback:: count: 0

Expand All @@ -187,7 +209,14 @@ Before running Immedidate callback:: count: 1

TestServerCancellationToken:: Cancellation is requested
Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":5}}
{
"seq": 0,
"type": "event",
"event": "requestCompleted",
"body": {
"request_seq": 5
}
}
TestServerCancellationToken:: resetRequest:: 5 is as expected
After running Immedidate callback:: count: 0

Expand Down Expand Up @@ -216,15 +245,31 @@ Before running Timeout callback:: count: 1
4: checkOne

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/a/app.ts","diagnostics":[]}}
{
"seq": 0,
"type": "event",
"event": "syntaxDiag",
"body": {
"file": "/a/app.ts",
"diagnostics": []
}
}
TestServerCancellationToken:: resetRequest:: 6 is as expected
After running Timeout callback:: count: 0

Before running Immedidate callback:: count: 1
2: semanticCheck

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/a/app.ts","diagnostics":[]}}
{
"seq": 0,
"type": "event",
"event": "semanticDiag",
"body": {
"file": "/a/app.ts",
"diagnostics": []
}
}
TestServerCancellationToken:: resetRequest:: 6 is as expected
After running Immedidate callback:: count: 1
3: suggestionCheck
Expand All @@ -233,9 +278,24 @@ Before running Immedidate callback:: count: 1
3: suggestionCheck

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/a/app.ts","diagnostics":[]}}
{
"seq": 0,
"type": "event",
"event": "suggestionDiag",
"body": {
"file": "/a/app.ts",
"diagnostics": []
}
}
Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":6}}
{
"seq": 0,
"type": "event",
"event": "requestCompleted",
"body": {
"request_seq": 6
}
}
TestServerCancellationToken:: resetRequest:: 6 is as expected
After running Immedidate callback:: count: 0

Expand Down Expand Up @@ -264,7 +324,15 @@ Before running Timeout callback:: count: 1
5: checkOne

Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/a/app.ts","diagnostics":[]}}
{
"seq": 0,
"type": "event",
"event": "syntaxDiag",
"body": {
"file": "/a/app.ts",
"diagnostics": []
}
}
TestServerCancellationToken:: resetRequest:: 7 is as expected
After running Timeout callback:: count: 0

Expand All @@ -283,7 +351,14 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] event:
{"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":7}}
{
"seq": 0,
"type": "event",
"event": "requestCompleted",
"body": {
"request_seq": 7
}
}
TestServerCancellationToken:: resetRequest:: 8 is as expected
Info seq [hh:mm:ss:mss] response:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2624,7 +2624,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,13 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] response:
{"seq":0,"type":"response","command":"configure","request_seq":1,"success":true}
{
"seq": 0,
"type": "response",
"command": "configure",
"request_seq": 1,
"success": true
}
Info seq [hh:mm:ss:mss] response:
{
"responseRequired": false
Expand Down
Loading