Skip to content

Commit 6cbac1e

Browse files
committed
test: logging
1 parent f97799f commit 6cbac1e

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

vscode-lean4/src/infoview.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,27 @@ export class InfoProvider implements Disposable {
212212
}
213213
const id = this.freshClientRequestId
214214
this.freshClientRequestId += 1
215-
const promise = client.sendRequest(method, params, tk.token).catch(async ex => {
216-
if (ex.code === RpcErrorCode.WorkerCrashed) {
217-
// ex codes related with worker exited or crashed
218-
logger.log(`[InfoProvider]The Lean Server has stopped processing this file: ${ex.message}`)
219-
await this.onWorkerStopped(uri, client, {
220-
message: 'The Lean Server has stopped processing this file: ',
221-
reason: ex.message as string,
222-
})
223-
}
224-
throw ex
225-
})
215+
logger.log(`[InfoProvider][trace] startClientRequest id=${id} method=${method} uri=${uri}`)
216+
const promise = client
217+
.sendRequest(method, params, tk.token)
218+
.then(res => {
219+
logger.log(`[InfoProvider][trace] startClientRequest id=${id} resolved`)
220+
return res
221+
})
222+
.catch(async ex => {
223+
logger.log(
224+
`[InfoProvider][trace] startClientRequest id=${id} rejected code=${ex?.code} msg=${ex?.message}`,
225+
)
226+
if (ex.code === RpcErrorCode.WorkerCrashed) {
227+
// ex codes related with worker exited or crashed
228+
logger.log(`[InfoProvider]The Lean Server has stopped processing this file: ${ex.message}`)
229+
await this.onWorkerStopped(uri, client, {
230+
message: 'The Lean Server has stopped processing this file: ',
231+
reason: ex.message as string,
232+
})
233+
}
234+
throw ex
235+
})
226236
this.clientRequests.set(id, [promise, sub, tk])
227237
return id
228238
}
@@ -691,6 +701,7 @@ export class InfoProvider implements Disposable {
691701
}
692702

693703
async onWorkerStopped(uri: string, client: LeanClient, reason: ServerStoppedReason) {
704+
logger.log(`[InfoProvider][trace] onWorkerStopped uri=${uri} reason=${reason.reason}`)
694705
await this.webviewPanel?.api.serverStopped(reason)
695706

696707
const extUri = parseExtUri(uri)
@@ -978,10 +989,14 @@ export class InfoProvider implements Disposable {
978989
private async sendPosition() {
979990
const editor = lean.activeLeanEditor
980991
if (editor === undefined) {
992+
logger.log('[InfoProvider][trace] sendPosition skipped: no active lean editor')
981993
return
982994
}
983995
const loc = this.getLocation(editor)
984996
const uri = editor.documentExtUri
997+
logger.log(
998+
`[InfoProvider][trace] sendPosition uri=${uri.toString()} clientsFailed=${this.clientsFailed.size} workersFailed=${this.workersFailed.size}`,
999+
)
9851000
if (this.clientsFailed.size > 0 || this.workersFailed.size > 0) {
9861001
const client = this.clientProvider.findClient(uri)
9871002
const uriKey = uri.toString()

vscode-lean4/src/leanclient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ export class LeanClient implements Disposable {
570570
const params = params_ as LeanFileProgressParams
571571
const uri = toExtUri(p2cConverter.asUri(params.textDocument.uri))
572572
if (uri !== undefined) {
573+
const kinds = (params.processing as any[]).map(p => p.kind).join(',')
574+
logger.log(`[LeanClient][trace] fileProgress uri=${uri.toString()} kinds=[${kinds}]`)
573575
this.progressChangedEmitter.fire([uri.toString(), params.processing])
574576
// save the latest progress on this Uri in case infoview needs it later.
575577
this.progress.set(uri, params.processing)

0 commit comments

Comments
 (0)